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

Daniel Peebles pumpkingod at gmail.com
Fri May 21 21:02:08 EDT 2010


Have you tried freopen on stderr?

On Fri, May 21, 2010 at 8:43 AM, Phyx <lonetiger at 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:nominolo at googlemail.com]
> Sent: Friday, May 21, 2010 12:53
> To: Phyx
> Cc: haskell-cafe at 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 <lonetiger at 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 at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> >
>
>
>
> --
> Push the envelope.  Watch it bend.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100521/f2b54c1b/attachment.html


More information about the Haskell-Cafe mailing list