
Beautiful, thank you. That worked.
On Tue, Jul 29, 2008 at 12:07 PM, allan
Hi
I had this same problem and I'm not sure my way is correct but I used 'Control.Monad.Trans.liftIO' Here is some code that I am using
{- The main program is pretty simple we just run the CGI action. -} main :: IO () main = Cgi.runCGI $ Cgi.handleErrors cgiMain
{- To be able to produce graphs which we can then display in the output webpage we require that our main function, that is the one which creates the page be in the IO monad. -} cgiMain :: CGI CGIResult cgiMain = do visitInfo <- getAnalysisData page <- Monad.Trans.liftIO $ createPage visitInfo Cgi.output $ Xhtml.renderHtml page
createPage :: Visit -> IO Html createPage ..... blah stuff you don't care about
getAnalysisData :: CGI Visit
Visit is a data type I've made to hold the information obtained from the page.
Hope this helps allan
Jefferson Heard wrote:
Please ignore the obvious security holes, as this is not a script meant for public consumption, but some internal testing and prototyping. I would like to write the result of my computation out to a file inside of cgiMain, but the type of the monad inside cgiMain is this odd CGIT IO CGIResult. I tried using liftM on writeFile, but it then complained that "newanns" was a string instead of a list of strings, which I don't understand at all. Here's the code:
DeleteAnnotation.hs:
[snip code]
-- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
-- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards