haskellghcpragmacompiler-optionslanguage-extension

Why does -XImplicitParams work only from the command line, not a pragma?


Why does -XImplicitParams work from the command line but not the OPTIONS_GHC pragma?

I've found that ghc t.hs throws a parse error on input 'a' if t.hs contains the following code, while ghc -XImplicitParams t.hs works fine. Ditto ghci.

{- OPTIONS_GHC -XImplicitParams -}
f :: (?a :: Int) => Int -> Int
f b = ?a + b
g c = f $ c+1

Solution

  • That would need to be a pragma, with {-# ... #-} delimiters. Better than an OPTIONS_GHC pragma is a

    {-# LANGUAGE ImplicitParams #-}
    

    pragma.