
24 Aug
2007
24 Aug
'07
11:11 a.m.
2007/8/24, Adrian Neumann
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ï