RE: MArrayt and runST
However the problem comes when I try and use runST to run it...
runMatrix :: Array (Int,Int) Int runMatrix = runST $ wrapper
This is becase 's' escapes Expected: ST s a -> b Inferred: (forall s1. ST s1 a) -> a
Delete the dollar? Cheers, Simon
Ahh, I see, perhaps you could give me a clue as to why (or how) this works... I have probably become a little over keen on using '$' as a general replacement for braces '(' ')' - the '$' was there because the actual wrapper function takes arguments and it looks neater not to have too many nested braces. I thought this could be something to do with runST enforcing strictness, but '$!' causes the same problem, only runST (wrapper x y z) appears to work - if its not too much trouble, how does runSTs type enforce this, and why does using '$' and '$!' cause type leakage? Regards, Keean Schupke. Simon Marlow wrote:
However the problem comes when I try and use runST to run it...
runMatrix :: Array (Int,Int) Int runMatrix = runST $ wrapper
This is becase 's' escapes Expected: ST s a -> b Inferred: (forall s1. ST s1 a) -> a
Delete the dollar?
Cheers, Simon _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Keean Schupke wrote:
Ahh, I see, perhaps you could give me a clue as to why (or how) this works... I have probably become a little over keen on using '$' as a general replacement for braces '(' ')' - the '$' was there because the actual wrapper function takes arguments and it looks neater not to have too many nested braces. I thought this could be something to do with runST enforcing strictness, but '$!' causes the same problem, only runST (wrapper x y z) appears to work - if its not too much trouble, how does runSTs type enforce this, and why does using '$' and '$!' cause type leakage?
Coincidentally, I tripped over this subtlety myself just last night. (I, too, often use '$' to avoid nested parentheses.) I concluded it was an instance of the "partial-application restriction" that I found described in section 7.11.4 of the GHC 5.02 User's Guide (still accessible at the GHC web site if you look carefully enough). [Simon: With a few minutes scanning, I couldn't find the same text in the current online User's Guide. Can you point out where it is?] -- Dean
participants (3)
-
Dean Herington -
Keean Schupke -
Simon Marlow