
Right, that modulename was being printed due to a trace statement in my code, so I’m now using withLocalCallbacks (\_ -> GhcApiCallbacks (\_ _ -> return ())) $ To override everything along with setting log_action to (\_ _ _ _ -> return ()). Now nothing else gets printed J Thanks for all the help, Phyx
I did some more digging around and it would seem that the error was being printed from the load call (depanal does some parsing ofcourse to find the imports).
I managed to silence that using loadWithLogger (const $ return ()) LoadAllTargets (maybe all these loggers should be consolidated).
That stopped it from showing part of the error, but can’t figure out what’s showing the module name at the end. “Printf”
From: Daniel Peebles [mailto:pumpkingod@gmail.com]
Sent: Saturday, May 22, 2010 03:02
To: Phyx
Cc: Thomas Schilling; haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr
Have you tried freopen on stderr?
On Fri, May 21, 2010 at 8:43 AM, Phyx
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Push the envelope. Watch it bend. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe