[Haskell-beginners] GHC as a library error.

Paulo Pocinho pocinho at gmail.com
Mon Oct 17 22:55:06 CEST 2011


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?



More information about the Beginners mailing list