[Haskell-cafe] Re: IO inside CGI
apfelmus
apfelmus at quantentunnel.de
Fri Aug 24 10:56:23 EDT 2007
Adrian Neumann wrote:
> Now I'd like to get a new StdGen, in case no id was supplied to the script.
>
> parse :: Maybe String-> IO StdGen
> parse (Just x) = return $ read x
> parse Nothing = getStdGen
>
> 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?
Abracadabra, the incantation is
liftIO :: IO a -> CGI a
i.e.
parse :: Maybe String-> CGI StdGen
parse (Just x) = return $ read x
parse Nothing = liftIO getStdGen
Regards,
apfelmus
More information about the Haskell-Cafe
mailing list