[Haskell-cafe] IO inside CGI
Chaddaï Fouché
chaddai.fouche at gmail.com
Fri Aug 24 11:11:01 EDT 2007
2007/8/24, Adrian Neumann <aneumann at inf.fu-berlin.de>:
> 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ï
More information about the Haskell-Cafe
mailing list