2007/8/24, Adrian Neumann <[EMAIL PROTECTED]>:
> Obviously this doesn't work because I'm trying to do IO inside CGI
> (right?). Is there some incantation I can perform to make this possible?
> Like
>
> gen <- arcaneMagic parse inp

As doing IO in the CGI Monad is a current need, it's an instance of
MonadIO and as such provide liftIO, so your arcaneMagic is called
liftIO :

cgiMain :: CGI CGIResult
cgiMain = do
       inp <- getInput "id"
       gen <- liftIO $ parse inp
       output $ take 10 (randoms gen)

parse :: Maybe String-> IO StdGen
parse (Just x) = return $ read x
parse Nothing = getStdGen

-- 
Jedaï
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to