shithub: MicroHs

ref: 63919e14c893dd09c3dc6ac6211becb794cfa9be
dir: /lib/Control/Monad/ST.hs/

View raw version
module Control.Monad.ST(
  ST,
  runST,
  ) where
import Prelude(); import MiniPrelude
import Primitives(primPerformIO)
import Control.Monad.ST_Type

runST :: forall a . (forall s . ST s a) -> a
runST (ST ioa) = primPerformIO ioa

instance forall s . Functor (ST s) where
  fmap f (ST x) = ST (fmap f x)

instance forall s . Applicative (ST s) where
  pure x = ST (pure x)
  ST x <*> ST y = ST (x <*> y)

instance forall s . Monad (ST s) where
  ST x >>= f = ST (x >>= (unST . f))