[Haskell-cafe] Fwd: GHC as a library error.

Paulo Pocinho pocinho at gmail.com
Tue Oct 18 00:34:47 CEST 2011


Forwarding to Haskell-Cafe:
I'm trying GHC as a library, as documented in:

http://www.haskell.org/haskellwiki/GHC/As_a_library
http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/ghc-as-a-library.html

However, this code:

import GHC
import GHC.Paths ( libdir )
import DynFlags ( defaultDynFlags )

main =
   defaultErrorHandler defaultDynFlags $ do
     runGhc (Just libdir) $ do
       dflags <- getSessionDynFlags
       setSessionDynFlags dflags
       target <- guessTarget "test_main.hs" Nothing
       setTargets [target]
       load LoadAllTargets


Produces:

Couldn't match expected type `Severity'
           with actual type `DynFlags.Settings'
Expected type: DynFlags.LogAction
 Actual type: DynFlags.Settings -> DynFlags
In the first argument of `defaultErrorHandler', namely
 `defaultDynFlags'
In the expression: defaultErrorHandler defaultDynFlags


How can I fix it?

Note: this was on a fresh install with latest stable GHC installer 7.2.1.



More information about the Haskell-Cafe mailing list