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.