Hi Pepe I would have liked something cross-platform.
Also, if stmt contains an error, wrapStmt will not be evaluated, and the resulting error is written to standard output or maybe to standard error. Whichever way, I am back to the same problem. Greetings, Mads Lindstrøm > I believe that the trick is to wrap your stmt in a IO handler that > captures stdout and returns it together with the value of your stmt. > That is, something with a type: > > wrapStmt :: IO a -> IO (a,String) > > It should be easy to implement wrapStmt using System.Posix.Process. > Then you just define > > runStmt' session stmt = runStmt session ("wrapStmt $ " ++ stmt) > > Good Luck! > > On 04/05/2007, at 18:04, Mads Lindstrøm wrote: > > > Hi > > > > I am trying to use GHC as a library (see > > http://haskell.org/haskellwiki/GHC/As_a_library ). I want to get > > all the > > output from an interactive session and put in a GUI. This > > http://haskell.org/sitewiki/images/5/51/Interactive.hs seemed to be a > > nice starting point. > > > > However, the result of: > > > > GHC.runStmt session stmt > > > > does not include the output of evaluating the statement (stmt above) - > > just the names of bound names. That is if stmt eqauls "3 + 5" then > > GHC.runStmt do not return a string equaling "8", but just the "it"- > > name > > (which is bound to 8). > > > > The output is printed to standard output :( And I do not see and easy > > way to get hold of it. The only way I see, is having the GUI in one > > process and "GHC as a library" in another process. > > > > Do anybody know of an easy way to get hold of the output from "GHC > > as a > > library" - the output currently printed to standard output? > > > > > > Greetings, > > > > Mads Lindstrøm > > > > _______________________________________________ > > Glasgow-haskell-users mailing list > > Glasgow-haskell-users@haskell.org > > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > > _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users