[Haskell-cafe] Re: Why do I need a 'do'?

Maurício briqueabraque at yahoo.com
Thu Apr 30 07:57:00 EDT 2009


>> import System.Random
>>
>> rollDice :: IO Int
>> rollDice = getStdRandom (randomR (1,6))
>>
>> rollNDice :: Int -> [IO Int]
>> rollNDice 0 = []
>> rollNDice n = rollDice : rollNDice (n-1)
> 
> 
> replicateM n rollDice
> 
> http://www.haskell.org/haskellwiki/Avoiding_IO#State_monad

Or, if you want the original idea:

sequence (rollNDice 10)

Check the type of sequence at Control.Monad.

Maurício



More information about the Haskell-Cafe mailing list