John Blackbox | 18 Jul 19:58 2013
Picon

Not working examples in GHC API documentation

Hi!
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
Johan Tibell | 18 Jul 20:08 2013
Picon

Re: Not working examples in GHC API documentation

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
>
John Blackbox | 18 Jul 20:10 2013
Picon

Re: Not working examples in GHC API documentation

Great, but how can we learn the API, when examples are not working? -.-


2013/7/18 Johan Tibell <johan.tibell <at> gmail.com>
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
>

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

Gmane