tweag / ormolu

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

Format base infix operators better when cabal file doesn't mention module #1032

Closed brandonchinn178 closed 1 year ago

brandonchinn178 commented 1 year ago

Describe the bug If you have a standalone Haskell file in a Cabal project (e.g. a Haskell script), Ormolu will find the cabal file, but it'll see that the cabal file doesn't mention the file and return ciDependencies = [].

To Reproduce Make a file test.hs with the following contents in a directory containing a .cabal file:

foo =
  unlines $
    hello <> world : ["Line " ++ show x | x <- [10 .. 20]]
  where
    hello = "hello"
    world = " world"

It will reformat as

foo =
  unlines
    $ hello
    <> world
    : ["Line " ++ show x | x <- [10 .. 20]]
  where
    hello = "hello"
    world = " world"

Expected behavior Formatting a Haskell file with a cabal file that doesn't mention it should be equivalent to formatting without a cabal file

Environment

Additional context Add any other context about the problem here.