tweag / ormolu

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

Ask ghc/cabal for --ghc-opts #517

Closed fisx closed 3 years ago

fisx commented 4 years ago

We are currently doing this:

LANGUAGE_EXTS=$(perl -ne '$x=1 if /default-extensions:/?1:(/^[^-]/?0:$x); print "--ghc-opt -X$1 " if ($x && /^- (.+)/);' package-defaults.yaml)
[...]
    ormolu [...] $LANGUAGE_EXTS [...]

... and various other hacks in our editor bindings.

I have very little insight into how feasible this would be, but it would be nice to have ormolu look at cabal file, package.yaml and all its imports, language extensions and options declared in the input file etc., and just always do the right thing.

I would be interested in any hints on how to do this, and any informed opinions on how hard it'd be. Still haven't decided what to do on https://zurihac.info this year. :)

mrkkrp commented 4 years ago

We try to keep Ormolu build-system agnostic, so that output for a particular source file is only determined by contents of that file.