-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imports long list align + list align behaviour regression when set to newline #462
Comments
## Summary This PR adjusts our `stylish-haskell` configuration to always import each symbol on a separate line. Example: ```hs import Some.Module.A ( SomeSymbolA1 , SomeSymbolA2 ) import Some.Module.B ( SomeSymbolB1 , SomeSymbolB2 , SomeSymbolB3 , SomeSymbolB4 ) ```` ## Details This change has several advantages: 1. **Better cross-version compatibility**: this configuration produces [almost exactly the same](731127c) output across versions `0.11.0.3` and `0.14.5.0` of `stylish-haskell` (current and latest versions respectively). 1. **Better cross-tool compatibility**: the output is almost identical to that produced by **`fourmolu`**. (See experimental `fourmolu` branch [here](https://github.com/cardano-foundation/cardano-wallet/pull/4061/files).) 1. **Improved diff-friendliness**: we virtually eliminate the problem where adding or removing a single import can lead to a multi-line diff. Adopting this style will make it easier to move to GHC `9.2` or `9.6`, both of which no longer work with our current version of `stylish-haskell`. ## Related Issues Without this change in our configuration, upgrading `stylish-haskell` from version `0.11.0.3` to `0.14.5.0` exposes us to the following regression: haskell/stylish-haskell#462
The documentation of these doesn't quite reflect the implementation and it seems to cause some confusion. This patch tries to address it by renaming `LongListAlign` constructors to better reflect what they do and fix their documentation in `stylish-haskell.yaml`. There is no change in functionality but it introduces a breaking change for users using the Haskell interface. It also adds a (lousy) concept of config option deprecation in form of documenting the deprecated variants in favor of new names. Related to haskell#462
This is a fun one!
Note that
The PR #467 tries to address this by introducing better names for constructors and their respective parser options.
Which is because
This is because the default stylish-haskell/lib/Language/Haskell/Stylish/Step/Imports.hs Lines 482 to 484 in 5503e27
But it is also the only
I'm not exactly sure, what is the right solution here
import Data.Map
( Map
) so it almost seems that there should be a Another possibility might be to deprecate |
In version 0.11.0.3, a configuration containing
was producing a nice consistent layout with all imported stuff in a new line and longer than 80 import lines broken in multiple lines
i.e. this test would have passed
But now, on 0.14.5.0, I cannot reproduce it. In fact, I get
where the
(Map)
is not on a new line.also, without the
longListAlign
, thelistAlign
option is respectedi.e. this test passes
Maybe I need a different combination of the options? Any help appreciated
The text was updated successfully, but these errors were encountered: