
19 Jul
2006
19 Jul
'06
7:33 p.m.
Chad Scherrer wrote:
x = runST $ return 1
y = runST $ do {r <- newSTRef 1; readSTRef r}
Neither of these works in ghci
x = runST (return 1) y = runST (do {r <- newSTRef 1; readSTRef r}) The escaping s is something to do with rank 2 polymorphism. (Search for "rank" in the ghc user guide, for example.) The hassle is that runST must always be applied to an argument (e.g. not passed to ($)), and a benefit is that you're protected from using an STRef you created in the context of one runST, in the context of another runST. Regards, Tom
6881
Age (days ago)
6881
Last active (days ago)
0 comments
1 participants
participants (1)
-
tpledger@ihug.co.nz