X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Control%2FMonad%2FST.hs;h=008dafc0b9f749923a65dd1e3ac662fa1a07734f;hb=57e487c332d1f428ee5ff85dbb32730d25a58235;hp=02d8d15d76530ec9f2d85f4a6d2370db1e71d568;hpb=746ef6a7fd71bb1e9ebe3cd107c5f9f79f3b7a68;p=ghc-base.git diff --git a/Control/Monad/ST.hs b/Control/Monad/ST.hs index 02d8d15..008dafc 100644 --- a/Control/Monad/ST.hs +++ b/Control/Monad/ST.hs @@ -2,27 +2,32 @@ -- | -- Module : Control.Monad.ST -- Copyright : (c) The University of Glasgow 2001 --- License : BSD-style (see the file libraries/core/LICENSE) +-- License : BSD-style (see the file libraries/base/LICENSE) -- -- Maintainer : libraries@haskell.org -- Stability : experimental -- Portability : non-portable (requires universal quantification for runST) -- --- The State Transformer Monad, ST +-- This library provides support for /strict/ state threads, as +-- described in the PLDI \'94 paper by John Launchbury and Simon Peyton +-- Jones /Lazy State Threads/. -- ----------------------------------------------------------------------------- module Control.Monad.ST - ( - ST -- abstract, instance of Functor, Monad, Typeable. - , runST -- :: (forall s. ST s a) -> a - , fixST -- :: (a -> ST s a) -> ST s a - , unsafeInterleaveST -- :: ST s a -> ST s a + ( + -- * The 'ST' Monad + ST, -- abstract, instance of Functor, Monad, Typeable. + runST, -- :: (forall s. ST s a) -> a + fixST, -- :: (a -> ST s a) -> ST s a - , unsafeIOToST -- :: IO a -> ST s a + -- * Unsafe operations + unsafeInterleaveST, -- :: ST s a -> ST s a + unsafeIOToST, -- :: IO a -> ST s a - , RealWorld -- abstract - , stToIO -- :: ST RealWorld a -> IO a + -- * Converting 'ST' to 'IO' + RealWorld, -- abstract + stToIO -- :: ST RealWorld a -> IO a ) where import Prelude @@ -30,6 +35,18 @@ import Prelude import Control.Monad.Fix import Data.Dynamic +#ifdef __HUGS__ +import Hugs.ST +import qualified Hugs.LazyST as LazyST + +fixST :: (a -> ST s a) -> ST s a +fixST f = LazyST.lazyToStrictST (LazyST.fixST (LazyST.strictToLazyST . f)) + +unsafeInterleaveST :: ST s a -> ST s a +unsafeInterleaveST = + LazyST.lazyToStrictST . LazyST.unsafeInterleaveST . LazyST.strictToLazyST +#endif + #ifdef __GLASGOW_HASKELL__ import GHC.ST import GHC.Base ( unsafeCoerce#, RealWorld )