[Haskell-cafe] Not working examples in GHC API documentation

Johan Tibell johan.tibell at gmail.com
Thu Jul 18 20:08:44 CEST 2013


I filed a bug a while back:

    http://ghc.haskell.org/trac/ghc/ticket/7752

Someone that understands the API needs to fix the doc. :)

On Thu, Jul 18, 2013 at 7:58 PM, John Blackbox
<blackbox.dev.ml at gmail.com> wrote:
> Hi!
> Please take a look here: http://www.haskell.org/haskellwiki/GHC/As_a_library
> The examples are not working. Even the simpelst one:
>
> import GHC
>
> import GHC.Paths ( libdir )
>
> import DynFlags ( defaultLogAction )
>
>
>
> main =
>
>     defaultErrorHandler defaultLogAction $ do
>
>       runGhc (Just libdir) $ do
>
>         dflags <- getSessionDynFlags
>
>         setSessionDynFlags dflags
>
>         target <- guessTarget "test_main.hs" Nothing
>
>         setTargets [target]
>
>         load LoadAllTargets
>
>
>
> throws:
>
>
> $> ghc -package ghc Main.hs
>
> [1 of 1] Compiling Main             ( Main.hs, Main.o )
>
> Main.hs:6:25:
>
>     Couldn't match type `DynFlags' with `[Char]'
>
>     Expected type: DynFlags.FatalMessager
>
>       Actual type: DynFlags.LogAction
>
>     In the first argument of `defaultErrorHandler', namely
>
>       `defaultLogAction'
>
>     In the expression: defaultErrorHandler defaultLogAction
>
>     In the expression:
>
>       defaultErrorHandler defaultLogAction
>
>       $ do { runGhc (Just libdir)
>
>              $ do { dflags <- getSessionDynFlags;
>
>                     setSessionDynFlags dflags;
>
>                     .... } }
>
> Main.hs:7:7:
>
>     Couldn't match expected type `DynFlags.FlushOut'
>
>                 with actual type `IO SuccessFlag'
>
>     In a stmt of a 'do' block:
>
>       runGhc (Just libdir)
>
>       $ do { dflags <- getSessionDynFlags;
>
>              setSessionDynFlags dflags;
>
>              target <- guessTarget "test_main.hs" Nothing;
>
>              setTargets [target];
>
>              .... }
>
>     In the second argument of `($)', namely
>
>       `do { runGhc (Just libdir)
>
>             $ do { dflags <- getSessionDynFlags;
>
>                    setSessionDynFlags dflags;
>
>                    .... } }'
>
>     In the expression:
>
>       defaultErrorHandler defaultLogAction
>
>       $ do { runGhc (Just libdir)
>
>              $ do { dflags <- getSessionDynFlags;
>
>                     setSessionDynFlags dflags;
>
>                     .... } }
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>




More information about the Haskell-Cafe mailing list