In GHCi instead of just setting unconditionally the extension ExtendedDefaultRules ON and the MonomorphismRestriction OFF, we first check, whether these extensions were not set on the command line.
- rGHC Glasgow Haskell Compiler
No Unit Test Coverage
- Build Status
Buildable 25459 Build 64630: [GHC] Linux/amd64: Continuous Integration Build 64629: [GHC] OSX/amd64: Continuous Integration Build 64628: [GHC] Windows/amd64: Continuous Integration Build 64627: arc lint + arc unit
Looks good, thanks. I suggest a minor refactoring
Presumably "The extensions..."
There is nothing in the comments on DynFlags.extensions to say that they are command line flags. Do you mean specifically the command line, or command line + LANGUAGE pragmas in the source file, + .ghci file + ??? Could you update the comments on DynFlags.extensions to say?
Why not put all this logic into a new function, in DynFlags. I think something like
unlessExplicitlySpecified :: LangExt.Extension -> (DynFlags -> LangExt.Extension -> DynFlags) -> DynFlags -> DynFlags
Invoked roughly as
dflags' = unlessExplicitlySpecified ExtendedDefaultRules xopt_set$ unlessExplicitlySpecified MonomorphismRestriction xopt_unset $ dflags
That might repeat the stripOnOrOff, but so be it. Or you could have a specialised version of elem inside unlessExplicitlySpecified.