Functions with multiple definitions are not grouped together in where blocks
I noticed where clauses don't group the bindings as one would expect. Example:
where
f :: Int -> Int
f 0 = 0
f _ = 42
ends up being formatted as:
where
f :: Int -> Int
f 0 = 0
f _ = 42
The Purescript AST represents this as 3 different bindings (1 for the type signatures and 2 different function definitions).
Here you need to change the suffix indentation when the successor is a binding for the same symbol https://gitlab.com/joneshf/purty/-/blob/master/internal/format/Format.hs#L2061
I implemented a fix in the fork that we use at work https://github.com/Zelenya/purty/pull/7 but when I tried to implement it here, I failed to even run the tests.
I looked into the Travis files and saw that the tests can be run with make test
but that fails on my machine.
make test output
make test
Downloading bazel binary
curl --location --output .build/bazel https://github.com/bazelbuild/bazel/releases/download/2.2.0/bazel-2.2.0-darwin-x86_64
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 649 100 649 0 0 1984 0 --:--:-- --:--:-- --:--:-- 1984
100 38.9M 100 38.9M 0 0 2457k 0 0:00:16 0:00:16 --:--:-- 7020k
.build/bazel version
Build label: 2.2.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Mar 3 09:28:15 2020 (1583227695)
Build timestamp: 1583227695
Build timestamp as int: 1583227695
.build/bazel test //...
INFO: Invocation ID: 2afc35ed-b44c-46b2-a632-50e7f960d3df
INFO: Call stack for the definition of repository 'stackage' which is a _stack_snapshot (rule definition at /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl:1024:19):
- <builtin>
- /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl:1241:5
- /Users/fghibellini/code/purty-gitlab/WORKSPACE.bazel:126:1
ERROR: An error occurred during the fetch of repository 'stackage':
Traceback (most recent call last):
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 919
_compute_dependency_graph(<6 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 799, in _compute_dependency_graph
_execute_or_fail_loudly(<2 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/private/workspace_utils.bzl", line 18, in _execute_or_fail_loudly
fail(<1 more arguments>)
Command failed: /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell_stack/stack --resolver /Users/fghibellini/code/purty-gitlab/snapshot.yaml ls dependencies --global-hints --separator=-
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-ast does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-cst does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
Cabal file warning in/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/stackage/pathwalk-0.3.1.2/pathwalk.cabal@4:1: The field "description" is specified more than once at positions 4:1, 14:1
Invariant violated: The 'purescript-ast' package was not found in any of the dependency sources
CallStack (from HasCallStack):
error, called at src/Stack/Dot.hs:373:17 in stack-2.3.1-uJmAnqRCkR1VKbFrmxCOZ:Stack.Dot
INFO: Call stack for the definition of repository 'rules_haskell_ghc_darwin_amd64' which is a _ghc_bindist (rule definition at /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/ghc_bindist.bzl:326:16):
- <builtin>
- /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/ghc_bindist.bzl:453:5
- /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/ghc_bindist.bzl:491:9
- /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/toolchain.bzl:314:5
- /Users/fghibellini/code/purty-gitlab/WORKSPACE.bazel:122:1
ERROR: /Users/fghibellini/code/purty-gitlab/cmd/purs-format/BUILD.bazel:31:1: //cmd/purs-format:purty depends on @stackage//:componentm in repository @stackage which failed to fetch. no such package '@stackage//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 919
_compute_dependency_graph(<6 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 799, in _compute_dependency_graph
_execute_or_fail_loudly(<2 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/private/workspace_utils.bzl", line 18, in _execute_or_fail_loudly
fail(<1 more arguments>)
Command failed: /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell_stack/stack --resolver /Users/fghibellini/code/purty-gitlab/snapshot.yaml ls dependencies --global-hints --separator=-
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-ast does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-cst does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
Cabal file warning in/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/stackage/pathwalk-0.3.1.2/pathwalk.cabal@4:1: The field "description" is specified more than once at positions 4:1, 14:1
Invariant violated: The 'purescript-ast' package was not found in any of the dependency sources
CallStack (from HasCallStack):
error, called at src/Stack/Dot.hs:373:17 in stack-2.3.1-uJmAnqRCkR1VKbFrmxCOZ:Stack.Dot
ERROR: /Users/fghibellini/code/purty-gitlab/cmd/purs-format/BUILD.bazel:31:1: //cmd/purs-format:purty depends on @stackage//:optparse-applicative in repository @stackage which failed to fetch. no such package '@stackage//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 919
_compute_dependency_graph(<6 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 799, in _compute_dependency_graph
_execute_or_fail_loudly(<2 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/private/workspace_utils.bzl", line 18, in _execute_or_fail_loudly
fail(<1 more arguments>)
Command failed: /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell_stack/stack --resolver /Users/fghibellini/code/purty-gitlab/snapshot.yaml ls dependencies --global-hints --separator=-
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-ast does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-cst does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
Cabal file warning in/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/stackage/pathwalk-0.3.1.2/pathwalk.cabal@4:1: The field "description" is specified more than once at positions 4:1, 14:1
Invariant violated: The 'purescript-ast' package was not found in any of the dependency sources
CallStack (from HasCallStack):
error, called at src/Stack/Dot.hs:373:17 in stack-2.3.1-uJmAnqRCkR1VKbFrmxCOZ:Stack.Dot
ERROR: /Users/fghibellini/code/purty-gitlab/cmd/purs-format/BUILD.bazel:31:1: //cmd/purs-format:purty depends on @stackage//:pathwalk in repository @stackage which failed to fetch. no such package '@stackage//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 919
_compute_dependency_graph(<6 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 799, in _compute_dependency_graph
_execute_or_fail_loudly(<2 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/private/workspace_utils.bzl", line 18, in _execute_or_fail_loudly
fail(<1 more arguments>)
Command failed: /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell_stack/stack --resolver /Users/fghibellini/code/purty-gitlab/snapshot.yaml ls dependencies --global-hints --separator=-
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-ast does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-cst does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
Cabal file warning in/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/stackage/pathwalk-0.3.1.2/pathwalk.cabal@4:1: The field "description" is specified more than once at positions 4:1, 14:1
Invariant violated: The 'purescript-ast' package was not found in any of the dependency sources
CallStack (from HasCallStack):
error, called at src/Stack/Dot.hs:373:17 in stack-2.3.1-uJmAnqRCkR1VKbFrmxCOZ:Stack.Dot
ERROR: /Users/fghibellini/code/purty-gitlab/cmd/purs-format/BUILD.bazel:31:1: //cmd/purs-format:purty depends on @stackage//:purescript-cst in repository @stackage which failed to fetch. no such package '@stackage//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 919
_compute_dependency_graph(<6 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 799, in _compute_dependency_graph
_execute_or_fail_loudly(<2 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/private/workspace_utils.bzl", line 18, in _execute_or_fail_loudly
fail(<1 more arguments>)
Command failed: /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell_stack/stack --resolver /Users/fghibellini/code/purty-gitlab/snapshot.yaml ls dependencies --global-hints --separator=-
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-ast does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-cst does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
Cabal file warning in/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/stackage/pathwalk-0.3.1.2/pathwalk.cabal@4:1: The field "description" is specified more than once at positions 4:1, 14:1
Invariant violated: The 'purescript-ast' package was not found in any of the dependency sources
CallStack (from HasCallStack):
error, called at src/Stack/Dot.hs:373:17 in stack-2.3.1-uJmAnqRCkR1VKbFrmxCOZ:Stack.Dot
ERROR: /Users/fghibellini/code/purty-gitlab/cmd/purs-format/BUILD.bazel:31:1: //cmd/purs-format:purty depends on @stackage//:rio in repository @stackage which failed to fetch. no such package '@stackage//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 919
_compute_dependency_graph(<6 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 799, in _compute_dependency_graph
_execute_or_fail_loudly(<2 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/private/workspace_utils.bzl", line 18, in _execute_or_fail_loudly
fail(<1 more arguments>)
Command failed: /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell_stack/stack --resolver /Users/fghibellini/code/purty-gitlab/snapshot.yaml ls dependencies --global-hints --separator=-
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-ast does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-cst does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
Cabal file warning in/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/stackage/pathwalk-0.3.1.2/pathwalk.cabal@4:1: The field "description" is specified more than once at positions 4:1, 14:1
Invariant violated: The 'purescript-ast' package was not found in any of the dependency sources
CallStack (from HasCallStack):
error, called at src/Stack/Dot.hs:373:17 in stack-2.3.1-uJmAnqRCkR1VKbFrmxCOZ:Stack.Dot
ERROR: Analysis of target '//test/golden:formatted/files/original/Array.purs' failed; build aborted: no such package '@stackage//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 919
_compute_dependency_graph(<6 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/cabal.bzl", line 799, in _compute_dependency_graph
_execute_or_fail_loudly(<2 more arguments>)
File "/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell/haskell/private/workspace_utils.bzl", line 18, in _execute_or_fail_loudly
fail(<1 more arguments>)
Command failed: /private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/rules_haskell_stack/stack --resolver /Users/fghibellini/code/purty-gitlab/snapshot.yaml ls dependencies --global-hints --separator=-
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-ast does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
DEPRECATED: The package at Repo from https://github.com/joneshf/purescript.git, commit 81909a9585b00bc99cc47c7959fbc5ae2e1ff285 in subdir lib/purescript-cst does not include a cabal file.
Instead, it includes an hpack package.yaml file for generating a cabal file.
This usage is deprecated; please see https://github.com/commercialhaskell/stack/issues/5210.
Support for this workflow will be removed in the future.
Cabal file warning in/private/var/tmp/_bazel_fghibellini/3be33a7ea1bb4e70f1ee5951e454c686/external/stackage/pathwalk-0.3.1.2/pathwalk.cabal@4:1: The field "description" is specified more than once at positions 4:1, 14:1
Invariant violated: The 'purescript-ast' package was not found in any of the dependency sources
CallStack (from HasCallStack):
error, called at src/Stack/Dot.hs:373:17 in stack-2.3.1-uJmAnqRCkR1VKbFrmxCOZ:Stack.Dot
INFO: Elapsed time: 3.162s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (24 packages loaded, 208 targets configured)
FAILED: Build did NOT complete successfully (24 packages loaded, 208 targets configured)
make: *** [test] Error 1