The release notes say: "The type of defaultErrorHandler has changed.
In particular, this means that you will normally want to pass it
defaultLogAction instead of defaultDynFlags".
(http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/release-7-2-1.html)".
defaultLogAction is in the DynFlags module, reexported by GHC. I
haven't tried it yet, though.
Unfortunately the documentation about using GHC as an API is often not
up to date. Even the API documentation is wrong: for example, the
documentation for the load function talks about a
reportModuleCompilationResult callback that doesn't exist any more,
and the release notes do not explain the changes to the load function
(loadWithLogger gone, etc).
You can look at the projects using the GHC API for inspiration, for
example the Scion library.

JP

On Tue, Oct 18, 2011 at 12:34 AM, Paulo Pocinho <poci...@gmail.com> wrote:
> 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.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
JP Moresmau
http://jpmoresmau.blogspot.com/

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to