GHCi 7.8.2 doesn't use language extensions from file

ghc, haskell

Solution

Is there an easy workaround (for example, telling GHCi to always use -XRebindableSyntax, which I will usually need?)

You can put a `.ghci` file in the same directory as your source files. Now if you start ghci from that directory, the `.ghci` file will be load and its content executed like the commands you type at the ghci prompt. In this case, you would put `:set -XRebindableSyntax` in there.

I think this is better than putting `:set -XRebindableSyntax` into the `.ghci` in your home directory because you might have other Haskell projects in other directories that need different extensions.

For more ideas what to put into project-specific ghci files, see Neil Mitchell's blog post.

Problem

Here's some simple code that requires `-XRebindableSyntax`. ``` {-# LANGUAGE RebindableSyntax, NoImplicitPrelude #-} import NumericPrelude import qualified Algebra.Additive (C) import qualified Algebra.Ring (C) newtype Foo = Foo Int deriving (Show) instance Algebra.Additive.C Foo where (Foo x) + (Foo y) = Foo (x+y) instance Algebra.Ring.C Foo where fromInteger = Foo . fromInteger f :: Foo -> Foo -> Foo f x y = x + y g = f 3 5 ``` Here's my GHCi transcript: ``` > ghci Foo.hs GHCi, version 7.8.2 ... *Main> g Foo 8 *Main> f 3 5 <interactive>:3:3: No instance for (GHC.Num.Num Foo) arising from the literal ‘3’ In the first argument of ‘f’, namely ‘3’ In the expression: f 3 5 In an equation for ‘it’: it = f 3 5 *Main> :set -XRebindableSyntax *Main> f 3 5 Foo 8 ``` I'm 95% sure that when I loaded a file with an extension prior to GHCi 7.8, I wouldn't have to reset that extension in GHCi. Is this documented somewhere, or is it a bug? Is there an easy workaround (for example, telling GHCi to always use `-XRebindableSyntax`, which I will usually need?)

Original source