Skip to content

Convenient default options #519

@sir4ur0n

Description

@sir4ur0n

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:

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:

Thank you for Ormolu and cheers!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions