-
Notifications
You must be signed in to change notification settings - Fork 89
Closed
Labels
Description
Hi,
Is there some way to configure the default GHC options (like extensions) not enabled by default, like XTypeApplications? We really don't want to repeat the pragma in each of our file...
For the moment what we do in my team is:
# shell.nix
let
# Wrap Ormolu to add our default extensions that are not enabled by default in Ormolu
# Run 'ormolu --manual-exts' to find out which extensions are not enabled by default
# Inspired by https://nixos.wiki/wiki/Nix_Cookbook
# If for whatever reason you want to reformat the whole code base, run:
# for f in ./**/*.hs; do
# ormolu --mode inplace "$f"
# done
ormolu-wrapped = symlinkJoin {
name = "ormolu";
paths = [ ormolu ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/ormolu \
--add-flags "\
--ghc-opt -XBangPatterns \
--ghc-opt -XTypeApplications \
"
'';
};
in
mkShell {
buildInputs = [
ormolu-wrapped
# Other build inputs
];
# Other conf, like env vars
}However:
- this feels hack-ish
- relies on Nix (+ don't forget to use
direnvor run inside a nix-shell otherwise the code will be changed, cf Guess that TypeApplications is used without being enabled #452 Ormolu changes the code) - it already seems that different people use different tricks (see Ask ghc/cabal for --ghc-opts #517 where they use Perl parsing)
I feel like supporting an Ormolu configuration file at the root of the project would be an improvement for such a use case.
I am aware of:
- Abolish ‘yaml’ configuration #157 (YAML configuration file support removed)
- Ask ghc/cabal for --ghc-opts #517 to automagically discover default extensions from build files. What I'm asking is simpler: support default configuration in a dedicated Ormolu file
Thank you for Ormolu and cheers!
Reactions are currently unavailable