GHCi should automatically enable language extensions found in a module
Motivation
When loading a file with {-# LANGUAGE OverloadedStrings #-}
with it, I always have to remember to :set -XOverloadedStrings
in GHCi as well — otherwise I can't use overloaded strings in the REPL. Same applies for -XOverloadedLabels
and a bunch of other extensions.
I have asked around and it looks like many people are surprised by this behavior. I am not sure why GHCi behaves this way, although perhaps I am missing a good reason.
(Yes, I can create a ~/.ghci
file and for a while I did so, but this breaks modules that fail to compile with overloaded strings.)
Proposal
I propose to automatically enable all language extensions found in a module when loading that module. Existing GHCi-default extensions (-XExtendedDefaultRules
, etc) should remain enabled as well, unless they are explicitly disabled in the file.