ormolu icon indicating copy to clipboard operation
ormolu copied to clipboard

Squash warnings about Setup.hs

Open donatello opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Most packages use a Setup.hs which is not directly used by stack or cabal, but is used by runhaskell (as mentioned here). Ormolu always prints a warning for this file:

Found .cabal file myapp/myapp.cabal, but it did not mention myapp/Setup.hs

Describe the solution you'd like Ormolu could recognize this as a known file when it finds a cabal file and simply attempt to format it.

Describe alternatives you've considered I've tried marking Setup.hs as an extra source file:

extra-source-file:
    Setup.hs

but this does not squash the warning and I am not sure if this is appropriate.

donatello avatar Sep 23 '22 18:09 donatello

Ormolu could recognize this as a known file when it finds a cabal file and simply attempt to format it.

Note that this message does not mean that Ormolu did not format the file. Rather, it means that Ormolu current logic couldn't find a corresponding .cabal file mentioning it, which is mostly for informational or debugging purposes.

But we certainly could special case Setup.hs in directories which also contain a .cabal file, and even also include package information based on setup-depends if present.


Also, as you hint at, in the huge majority of cases (i.e. non-ancient cabal version and build-type: Simple, which has been the default since cabal-version: 2.2), the Setup.hs file can simply be deleted without any consequence. cabal init also does no longer create Setup.hs.

amesgen avatar Sep 23 '22 18:09 amesgen

Also, as you hint at, in the huge majority of cases (i.e. non-ancient cabal version and build-type: Simple, which has been the default since cabal-version: 2.2), the Setup.hs file can simply be deleted without any consequence. cabal init also does no longer create Setup.hs.

Ah that's good - in most of my cases, I can remove this file then. 👍🏾

donatello avatar Sep 23 '22 19:09 donatello