tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
950 stars 83 forks source link

Ormolu Live: exclude certain packages with conflicting modules #1029

Closed amesgen closed 1 year ago

amesgen commented 1 year ago

Since we made all packages available in Ormolu Live by default in #1015, there are some surprising discrepancies between the CLI and Ormolu Live, for example:

Input, also a fixed point in the CLI Output in current Ormolu Live
```haskell foo = bar $ baz ``` ```haskell foo = bar $ baz ```
```haskell -- with -p lens import Control.Lens foo = bar & a .~ 1 & b .~ 2 ``` ```haskell -- with -p lens import Control.Lens foo = bar & a .~ 1 & b .~ 2 ```

Another example is the snippet from #1028. With this PR, all of them are now also fixed points in Ormolu Live.


The reason for this is that certain modules (Prelude and Control.Lens) are also defined in other packages than the "obvious" candidates, but the operators there are inferred to have a different fixity, so we get suboptimal layout as above.

Concretely, I have noticed two cases:


In order to fix this in Ormolu Live, we are now excluding all packages that also define a module present in one of a few selected packages (currently, only base and lens). Concretely, the complement of liveDependencies is

["NonEmptyList","Prelude","Semigroup","bizzlelude","fay-base","haskell2010","haskell2020","haskell98","hs-functors","morley-prelude","reasonable-lens","simpleprelude"]

In general, I don't think there are many packages that both share module names and suffer from operator fixity discrepancies due to one of the reasons above, so a static list seems fine to me.

github-actions[bot] commented 1 year ago

🚀 Deployed on https://3d899c71f69f8aa2a160c2cadae7cf20f05f4a90--ormolu-live.netlify.app