[Haskell-cafe] making the GHC Api not write to stderr
Phyx
lonetiger at gmail.com
Thu May 20 14:05:18 EDT 2010
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100520/220628cf/attachment.html
More information about the Haskell-Cafe
mailing list