tweag / ormolu

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

Ormolu doesn't take Cabal mixins into account #1052

Closed brandonchinn178 closed 1 year ago

brandonchinn178 commented 1 year ago

Describe the bug The issue in #1032 still occurs if the base dependency is imported from a common stanza

To Reproduce

name: foo
version: 0

common base
  build-depends: base

library
  import: base
  exposed-modules: Foo
module Foo where

foo :: Int
foo =
  (+ 1) $
    (+ 2) $
      3

Ormolu returns

  foo :: Int
  foo =
-   (+ 1) $
-     (+ 2) $
-       3
+   (+ 1)
+     $ (+ 2)
+     $ 3

Expected behavior The snippet should not reformat.

Environment

Additional context Add any other context about the problem here.

amesgen commented 1 year ago

Hmm, thanks for the report, but I don't think this is related to Ormolu; rather, common stanzas were introduced in cabal-version: 2.2, but as you don't specify a cabal-version, the common stanza is (silently?) ignored. When I add

cabal-version: 2.2

to the top of your .cabal file, Ormolu formats the module as one would expect (i.e. it stays as it is).

Does that make sense?

brandonchinn178 commented 1 year ago

Ah you're right, sorry about the false positive.