<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>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).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I managed to silence that using loadWithLogger (const $ return ()) LoadAllTargets (maybe all these loggers should be consolidated).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>That stopped it from showing part of the error, but can’t figure out what’s showing the module name at the end. “Printfâ€<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Daniel Peebles [mailto:pumpkingod@gmail.com] <br><b>Sent:</b> Saturday, May 22, 2010 03:02<br><b>To:</b> Phyx<br><b>Cc:</b> Thomas Schilling; haskell-cafe@haskell.org<br><b>Subject:</b> Re: [Haskell-cafe] making the GHC Api not write to stderr<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Have you tried freopen on stderr?<o:p></o:p></p><div><p class=MsoNormal>On Fri, May 21, 2010 at 8:43 AM, Phyx <<a href="mailto:lonetiger@gmail.com">lonetiger@gmail.com</a>> wrote:<o:p></o:p></p><p class=MsoNormal>Hi,<br>I tried that, setting it to (\_ _ _ _ -> return ()) and it still did the<br>same, also tried setting it to undefined to see whether the code that's<br>printing the error is using it, and it didn't crash<br>So I assume it's not.<br><br>-----------<br>*VsxParser> getModInfo True<br>"C:\\Users\\Phyx\\AppData\\Local\\Temp\\tmp5600.hs"<br>"" >> return ()<br><br>C:\Users\Phyx\AppData\Local\Temp\tmp5600.hs:11:13:<br> parse error on input `='<br>Printf<br>---------<br><br>I think parseModule might still have a hardcoded print statement in it.<o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>-----Original Message-----<br>From: Thomas Schilling [mailto:<a href="mailto:nominolo@googlemail.com">nominolo@googlemail.com</a>]<br>Sent: Friday, May 21, 2010 12:53<br>To: Phyx<br>Cc: <a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr<o:p></o:p></p></div><div><div><p class=MsoNormal>You could try changing the log_action[1] member of the DynFlags. A while<br>ago I turned most printed errors into some form of error message, but I<br>wouldn't be surprised if I missed some places. All output should go through<br>log_action, though, so try changing that to intercept any output.<br><br>[1]:<br><a href="http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h%0d%0atml#v%3Alog_action" target="_blank">http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h<br>tml#v%3Alog_action</a><br><br>On 20 May 2010 19:05, Phyx <<a href="mailto:lonetiger@gmail.com">lonetiger@gmail.com</a>> wrote:<br>> I was wondering how to forcibly quiet down the API. I have a custom<br>> handler in place, but when I call the function on failure both my<br>> handler gets called and somewhere somehow errors get printed to the<br>> stderr, which I really need to avoid.<br>><br>><br>><br>> My current code looks like<br>><br>><br>><br>> getModInfo :: Bool -> String -> String -> IO (ApiResults ModuleInfo)<br>><br>> getModInfo qual file path = handleSourceError processErrors $<br>><br>> runGhc (Just libdir) $ do<br>><br>> dflags <- getSessionDynFlags<br>><br>> setSessionDynFlags $ configureDynFlags dflags<br>><br>> target <- guessTarget file Nothing<br>><br>> addTarget target<br>><br>> setSessionDynFlags $ dflags { importPaths = [path] }<br>><br>> load LoadAllTargets<br>><br>> graph <- depanal [] False<br>><br>> let modifier = moduleName . ms_mod<br>><br>> modName = modifier $ head graph<br>><br>> includes = includePaths dflags<br>><br>> imports = importPaths dflags<br>><br>><br>><br>> dflags' <- Debug.trace (moduleNameString modName)<br>> getSessionDynFlags<br>><br>> setSessionDynFlags $ dflags' { includePaths = path:includes<br>><br>> , importPaths = path:imports<br>><br>> }<br>><br>><br>><br>> parsed <- parse modName<br>><br>> checked <- typecheckModule parsed<br>><br>> _______________________________________________<br>> Haskell-Cafe mailing list<br>> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>><br>><br><br><br><br>--<br>Push the envelope. Watch it bend.<br><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><o:p></o:p></p></div></div></div><p class=MsoNormal><o:p> </o:p></p></div></body></html>