15 Nov
2009
15 Nov
'09
5:08 a.m.
Before looking into the actual source code of the ST monad, I thought that ST must be something like newtype ST s a = ST (IO a) where the strict ST monad is based on normal IO bind function and lazy ST monad also uses unsafeInterleaveIO. Then runST would be just an unsafePerformIO. However when looking into http://darcs.haskell.org/packages/st it is in Control.Monad.ST.Lazy newtype ST s a = ST (State s -> (a, State s)) data State s = S# (State# s) and in Hugs.ST: newtype ST s a = ST (forall r. (a -> r) -> r) Both GHC and Hugs seem to use primitives, that are not available in JHC. Would my IO definition above be correct, at all? It seems that much of the code in the 'st' package could not be re-used in JHC.