On 29/12/2011 19:21, Heinrich Apfelmus wrote:
Why would IO Int be something special or mysterious? It's an
ordinary value like everything else; it's on the same footing as
[Char], Maybe Int, Int -> String, Bool, and so on. I see no difference
between the list [1,2,3] :: [Int] and the action "pick a random
number between 1 and 6" :: IO Int .
Because performing the action (as part of extracting the result out of
it) is relevant to the semantics of the language too, whether an IO
monadic random generator or an an interaction with the user via a GUI or
whatever.
BTW - why use an IO action for random number generation? There's a
perfectly good pure generator. It's probably handy to treat it
monadically to sequence the generator state/seed/whatever but random
number generation can be completely pure.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe