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

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

Reply via email to