Skip to content

Commit

Permalink
futhark fmt: improve formatting of value specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Jan 14, 2025
1 parent 7f15f73 commit bb6e919
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* `futhark fmt`: do not throw away doc comments for `local`
definitions.

* `futhark fmt`: improve formatting of value specs.

## [0.25.25]

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Futhark/Fmt/Printer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ instance Format UncheckedSpec where
where
sub
| null ps = fmtName bindingStyle name
| otherwise = fmtName bindingStyle name <+> align (sep line $ map fmt ps)
| otherwise = fmtName bindingStyle name <+> align (sep space $ map fmt ps)
fmt (ModSpec name mte doc loc) =
addComments loc $ fmt doc <> "module" <+> fmtName bindingStyle name <> ":" <+> fmt mte
fmt (IncludeSpec mte loc) = addComments loc $ "include" <+> fmt mte
Expand Down
7 changes: 7 additions & 0 deletions tests_fmt/expected/modules.fut
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ module type mt4 = {
val g [n] :
[n]i32
-> [n]i32

val block [m1] [m2] [n1] [n2] :
(A: [m1][n1]i32)
-> (B: [m1][n2]i32)
-> (C: [m2][n1]i32)
-> (D: [m2][n2]i32)
-> [m1 + m2][n1 + n2]i32
}

module pm1 (P: {}) : {} = {
Expand Down
3 changes: 3 additions & 0 deletions tests_fmt/modules.fut
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ module type mt4 = {
-> [n]i32


val block [m1] [m2] [n1] [n2] :
(A: [m1][n1]i32) -> (B: [m1][n2]i32) -> (C: [m2][n1]i32) -> (D: [m2][n2]i32)
-> [m1 + m2][n1 + n2]i32
}

module pm1 (P: {}) : {} = {
Expand Down

0 comments on commit bb6e919

Please sign in to comment.