module Control.Monad.ST( ST, runST, fixST, -- RealWorld, stToIO, -- GHC compat ) whereimport qualified Prelude(); import MiniPreludeimport Primitives(primPerformIO)import Control.Monad.Fiximport Control.Monad.ST_Typeimport System.IO(fixIO)runST :: (forall s . ST s a) -> arunST (ST ioa) = primPerformIO ioafixST :: (a -> ST s a) -> ST s afixST f = ST (fixIO (unST . f))instance Functor (ST s) where fmap f (ST x) = ST (fmap f x)instance Applicative (ST s) where pure x = ST (pure x) ST x <*> ST y = ST (x <*> y)instance Monad (ST s) where ST x >>= f = ST (x >>= (unST . f))instance MonadFix (ST s) where mfix = fixST----------------------------------- This does not belong here since it's GHC specific,-- but to be compatible we do it the same way.data RealWorld -- Just to be compatible with GHC. We don't use it.stToIO :: ST RealWorld a -> IO astToIO = unST