From: simonm Date: Wed, 17 Dec 1997 11:21:44 +0000 (+0000) Subject: [project @ 1997-12-17 11:21:44 by simonm] X-Git-Tag: Approx_2487_patches~1164 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c853c617d1b305baa4e7779ed436ec4fae84cedb;p=ghc-hetmet.git [project @ 1997-12-17 11:21:44 by simonm] Add runST. --- diff --git a/ghc/lib/glaExts/LazyST.lhs b/ghc/lib/glaExts/LazyST.lhs index 3d457ca..d18b716 100644 --- a/ghc/lib/glaExts/LazyST.lhs +++ b/ghc/lib/glaExts/LazyST.lhs @@ -12,6 +12,7 @@ module LazyST ( ST, + runST, unsafeInterleaveST, -- ST is one, so you'll likely need some Monad bits @@ -35,6 +36,7 @@ import qualified UnsafeST ( unsafeInterleaveST ) import PrelBase ( Eq(..), Int, Bool, ($), ()(..) ) import Monad import Ix +import GHC newtype ST s a = ST (STBase.State s -> (a,STBase.State s)) @@ -50,6 +52,10 @@ instance Monad (ST s) where ST k_a = k r in k_a new_s + +-- ToDo: un-inline this, it could cause problems... +runST :: (All s => ST s a) -> a +runST st = case st of ST st -> let (r,_) = st (STBase.S# realWorld#) in r \end{code} %*********************************************************