tweag / ormolu

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

Refactor extraction and caching of CabalInfo #1034

Open brandonchinn178 opened 1 year ago

brandonchinn178 commented 1 year ago

Broken off from #1033

This change has the following improvements:

  1. Force user to handle missing stanza information (e.g. dependencies) when the cabal file does not mention a source file
    • This would make it much harder to have the same regression as #1032 somewhere else
  2. Make CabalInfo return all info for the cabal file, without reference to the source file
    • Simplifies parseCabalInfo as just "parse cabal file", not "parse cabal file + extract info relevant to given source file"
    • IMO this is clearer, given the names of the types and functions.
mrkkrp commented 1 year ago

I'm happy with the first commit, which I adjusted a bit to apply the new helper to both caching of cabal files and .ormolu files, however I don't think we can easily merge something that changes the signature of refineConfig because it changes the API, which we are supposed to keep backwards compatible now as per c81320d8a1069674c17fa5ee52b64c18604f84de.

brandonchinn178 commented 1 year ago

Ah sure, I could make the changes backwards compatible. Give me a second

brandonchinn178 commented 1 year ago

@mrkkrp how's that?

Also, there's a weeder failure. Maybe weeder.dhall should be updated to include the Ormolu module as a root?

mrkkrp commented 1 year ago

Eh, I like splitting the code in two branches (old and new) even less. Let's apply d91bbd064511fee913bd348fc413ba5a820e8927 and keep the rest on the shelf for a while until we decide to release 0.8.0.0 at which point we can make a clean break.

brandonchinn178 commented 1 year ago

Sure up to you