Not working examples in GHC API documentation

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; .... } }

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
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Great, but how can we learn the API, when examples are not working? -.-
2013/7/18 Johan Tibell
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
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
Johan Tibell
-
John Blackbox