<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Mads<DIV><BR><DIV><DIV>On 04/05/2007, at 19:19, Mads Lindstrøm wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">Hi Pepe</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">I would have liked something cross-platform.</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><BR></P></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Take a look at the unix-compat[1] package by Bjorn Bringert, although it looks like it won't help you. Maybe it can be extended.</DIV><BR><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">Also, if stmt contains an error, wrapStmt will not be evaluated, and the</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">resulting error is written to standard output or maybe to standard</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">error. Whichever way, I am back to the same problem.</FONT></P> </BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>What else should be the behaviour in the case stmt contains an error?</DIV><DIV>You can capture errors and stop them being written out very easily. </DIV><DIV>Take a look at this snippet (not mine, it's beschmi's code) from Shim[2]:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>\begin{code}</DIV><DIV>load' :: FilePath -> Maybe String -> SHM (SuccessFlag,[CompileNote],Session)</DIV><DIV>load' sourcefile source = do</DIV><DIV> source' <- addTime source</DIV><DIV> ses <- getSessionFor sourcefile</DIV><DIV> dflags0 <- io $ GHC.getSessionDynFlags ses</DIV><DIV> ref <- io $ MVar.newMVar []</DIV><DIV> let dflags1 = dflags0{ log_action = logMsg ref }</DIV><DIV> io $ GHC.setSessionDynFlags ses dflags1</DIV><DIV> io $ GHC.setTargets ses [Target (TargetFile sourcefile Nothing) source']</DIV><DIV> loadResult <- io $ GHC.load ses LoadAllTargets</DIV><DIV> cnotes <- io $ reverse `liftM` MVar.readMVar ref</DIV><DIV> case loadResult of</DIV><DIV> Succeeded -> do -- GHC takes care of setting the right context</DIV><DIV> modq <- io $ findModuleInFile ses sourcefile</DIV><DIV> io $ GHC.setContext ses [modq] []</DIV><DIV> return (Succeeded,cnotes,ses)</DIV><DIV> Failed -> do -- We take care of getting at least the Prelude</DIV><DIV> io(GHC.setContext ses [] =<< atomM (getPrelude ses))</DIV><DIV> return (Failed,cnotes,ses)</DIV><DIV> where atomM = liftM (:[])</DIV><DIV> logMsg ref severity' srcSpan' style' msg' = do</DIV><DIV> dir <- getCurrentDirectory</DIV><DIV> logS ('\n':show ((mkLocMessage srcSpan' msg') style'))</DIV><DIV> MVar.modifyMVar_ ref</DIV><DIV> (\l -> return $ (CompileNote severity' srcSpan'</DIV><DIV> style' msg' dir):l)</DIV><DIV>\end{code}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Here, DynFlags.logAction is being filled with a handler that writes to a MVar instead of the default handler that writes to stdout.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>pepe</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>[1] - <A href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unix-compat-0.1">http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unix-compat-0.1</A></DIV><DIV>[2] - <A href="http://shim.haskellco.de/shim/Shim/Hsinfo.hs">http://shim.haskellco.de/shim/Shim/Hsinfo.hs</A></DIV></DIV></BODY></HTML>