[Haskell-cafe] making the GHC Api not write to stderr

Phyx lonetiger at gmail.com
Thu May 20 16:15:13 EDT 2010


Hi,
Unfortunately hint does not provide the functionality I require,  and from
what  I remember about hint they also use the GHC API, I guess the problem
here is the defaultErrorhandlers that is in initGhcMonad . I've been
wondering if I give my own implementation, one that doesn't do any printing
at all and reimplement initGhcMonad I can maybe get the desired result but
I'm not sure

-----Original Message-----
From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Martin Hilbig
Sent: Thursday, May 20, 2010 21:45
To: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr

hi,

i tried this too, but i did not get it. a very nice workaround is to use 
hint [1].

have fun
martin

[1]: http://hackage.haskell.org/package/hint

On 20.05.2010 20:05, Phyx wrote:
> I was wondering how to forcibly quiet down the API. I have a custom
> handler in place, but when I call the function on failure both my
> handler gets called and somewhere somehow errors get printed to the
> stderr, which I really need to avoid.
>
> My current code looks like
>
> getModInfo :: Bool -> String -> String -> IO (ApiResults ModuleInfo)
>
> getModInfo qual file path = handleSourceError processErrors $
>
> runGhc (Just libdir) $ do
>
> dflags <- getSessionDynFlags
>
> setSessionDynFlags $ configureDynFlags dflags
>
> target <- guessTarget file Nothing
>
> addTarget target
>
> setSessionDynFlags $ dflags { importPaths = [path] }
>
> load LoadAllTargets
>
> graph <- depanal [] False
>
> let modifier = moduleName . ms_mod
>
> modName = modifier $ head graph
>
> includes = includePaths dflags
>
> imports = importPaths dflags
>
> dflags' <- Debug.trace (moduleNameString modName) getSessionDynFlags
>
> setSessionDynFlags $ dflags' { includePaths = path:includes
>
> , importPaths = path:imports
>
> }
>
> parsed <- parse modName
>
> checked <- typecheckModule parsed
>
>
>
> _______________________________________________
> 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



More information about the Haskell-Cafe mailing list