
19 Aug
2013
19 Aug
'13
1:36 a.m.
On 08/19/2013 05:04 AM, David McBride wrote:
I'm not exactly sure why you get the error, but the easiest way to fix it is just to type it this way:
runSimulation :: Word32 -> [Int] runSimulation seed = runST $ do gen <- initialize (singleton seed) whileM (do r1 <- uniformR (-1.0, 1.0 :: Double) gen if r1 > 0.0 then return True else return False) (do r2 <- uniformR (0, 10 :: Int) gen if r2 > 5 then return r2 else return 0)
It has something to do with the forall s in runST, although I'm not completely sure what.
Thanks, this is clearly the most easy way to fix the problem. But the question remains - why the line "do r1 <- uniformR (-1.0, 1.0 :: Double) gen" cannot be annotated with ST s Double?