$ ghci
GHCi, version 6.8.3
Prelude> import Random
Prelude Random> let g = mkStdGen 1
Prelude Random> (fst (random g)) + 0
-604496784
Prelude Random> (fst (random g)) / 1
0.35925462466181596
Prelude Random> (fst (random g)) * 1
-604496784
Prelude Random> (fst (random g)) * 1.0
0.35925462466181596
Yes, it is a feature. Haskell's random changes its behavior by what type inferred. See The Haskell 98 Library Report: Random Numbers.
No comments:
Post a Comment