RE: [Haskell-cafe] making the GHC Api not write to stderr
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:pumpkin...@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 loneti...@gmail.com wrote: Hi, I tried that, setting it to (\_ _ _ _ - return ()) and it still did the same, also tried setting it to undefined to see whether the code that's printing the error is using it, and it didn't crash So I assume it's not. --- *VsxParser getModInfo True C:\\Users\\Phyx\\AppData\\Local\\Temp\\tmp5600.hs return () C:\Users\Phyx\AppData\Local\Temp\tmp5600.hs:11:13: parse error on input `=' Printf - I think parseModule might still have a hardcoded print statement in it. -Original Message- From: Thomas Schilling [mailto:nomin...@googlemail.com] Sent: Friday, May 21, 2010 12:53 To: Phyx Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr You could try changing the log_action[1] member of the DynFlags. A while ago I turned most printed errors into some form of error message, but I wouldn't be surprised if I missed some places. All output should go through log_action, though, so try changing that to intercept any output. [1]: http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h%0d%0atml#v%3Alog_action tml#v%3Alog_action On 20 May 2010 19:05, Phyx loneti...@gmail.com 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@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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] making the GHC Api not write to stderr
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:pumpkin...@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 loneti...@gmail.com wrote: Hi, I tried that, setting it to (\_ _ _ _ - return ()) and it still did the same, also tried setting it to undefined to see whether the code that's printing the error is using it, and it didn't crash So I assume it's not. --- *VsxParser getModInfo True C:\\Users\\Phyx\\AppData\\Local\\Temp\\tmp5600.hs return () C:\Users\Phyx\AppData\Local\Temp\tmp5600.hs:11:13: parse error on input `=' Printf - I think parseModule might still have a hardcoded print statement in it. -Original Message- From: Thomas Schilling [mailto:nomin...@googlemail.com] Sent: Friday, May 21, 2010 12:53 To: Phyx Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr You could try changing the log_action[1] member of the DynFlags. A while ago I turned most printed errors into some form of error message, but I wouldn't be surprised if I missed some places. All output should go through log_action, though, so try changing that to intercept any output. [1]: http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h%0d%0atml#v%3Alog_action tml#v%3Alog_action On 20 May 2010 19:05, Phyx loneti...@gmail.com 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@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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] making the GHC Api not write to stderr
You could try changing the log_action[1] member of the DynFlags. A while ago I turned most printed errors into some form of error message, but I wouldn't be surprised if I missed some places. All output should go through log_action, though, so try changing that to intercept any output. [1]: http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.html#v%3Alog_action On 20 May 2010 19:05, Phyx loneti...@gmail.com 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@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
RE: [Haskell-cafe] making the GHC Api not write to stderr
Hi, I tried that, setting it to (\_ _ _ _ - return ()) and it still did the same, also tried setting it to undefined to see whether the code that's printing the error is using it, and it didn't crash So I assume it's not. --- *VsxParser getModInfo True C:\\Users\\Phyx\\AppData\\Local\\Temp\\tmp5600.hs return () C:\Users\Phyx\AppData\Local\Temp\tmp5600.hs:11:13: parse error on input `=' Printf - I think parseModule might still have a hardcoded print statement in it. -Original Message- From: Thomas Schilling [mailto:nomin...@googlemail.com] Sent: Friday, May 21, 2010 12:53 To: Phyx Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr You could try changing the log_action[1] member of the DynFlags. A while ago I turned most printed errors into some form of error message, but I wouldn't be surprised if I missed some places. All output should go through log_action, though, so try changing that to intercept any output. [1]: http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h tml#v%3Alog_action On 20 May 2010 19:05, Phyx loneti...@gmail.com 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@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
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 loneti...@gmail.com wrote: Hi, I tried that, setting it to (\_ _ _ _ - return ()) and it still did the same, also tried setting it to undefined to see whether the code that's printing the error is using it, and it didn't crash So I assume it's not. --- *VsxParser getModInfo True C:\\Users\\Phyx\\AppData\\Local\\Temp\\tmp5600.hs return () C:\Users\Phyx\AppData\Local\Temp\tmp5600.hs:11:13: parse error on input `=' Printf - I think parseModule might still have a hardcoded print statement in it. -Original Message- From: Thomas Schilling [mailto:nomin...@googlemail.com] Sent: Friday, May 21, 2010 12:53 To: Phyx Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr You could try changing the log_action[1] member of the DynFlags. A while ago I turned most printed errors into some form of error message, but I wouldn't be surprised if I missed some places. All output should go through log_action, though, so try changing that to intercept any output. [1]: http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h tml#v%3Alog_action On 20 May 2010 19:05, Phyx loneti...@gmail.com 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@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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] making the GHC Api not write to stderr
I've thought about that, but my specific problem is that I'm calling the Haskell code compiled to a shared lib and then hPutStr is failing, presumable because there is no valid stderr (and I would image also no stdin or out). So in order for me to use that method I would have to create a new file handle and direct stderr to that. Or somehow create a fake Handle and pass it that. Or another alternative is on the side where I call the lib, create and attach some hidden console to the process and have it write there. But that all seems like a hackish way out, It would be best if the API just allowed me to turn off this behavior of writing to stderr. From: Jean-Denis Koeck [mailto:jdko...@gmail.com] Sent: Thursday, May 20, 2010 21:59 To: Phyx Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr Maybe this http://nominolo.blogspot.com/2010/04/haskell-tip-redirect-stdout-in-haskell .html could help you ? 2010/5/20 Phyx loneti...@gmail.com 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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] making the GHC Api not write to stderr
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-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Martin Hilbig Sent: Thursday, May 20, 2010 21:45 To: haskell-cafe@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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe