| Copyright | (c) The University of Glasgow 2001 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | libraries@haskell.org |
| Stability | experimental |
| Portability | non-portable (requires universal quantification for runST) |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Control.Monad.ST.Safe
Contents
Description
Deprecated: Safe is now the default, please use Control.Monad.ST instead
This library provides support forstrict state threads, as described in the PLDI '94 paper by John Launchbury and Simon Peyton JonesLazy Functional State Threads.
Safe API Only.
ST MonadThe strict state-transformer monad. A computation of type transforms an internal state indexed byST s as, and returns a value of typea. Thes parameter is either
runST), orRealWorld (inside invocations ofstToIO).It serves to keep the internal states of different invocations ofrunST separate from each other and from invocations ofstToIO.
The>>= and>> operations are strict in the state (though not in values stored in the state). For example,
runST (writeSTRef _|_ v >>= f) = _|_| Monad (ST s)Source# | Since: 2.1 |
| Functor (ST s)Source# | Since: 2.1 |
| MonadFix (ST s)Source# | Since: 2.1 |
| MonadFail (ST s)Source# | Since: 4.11.0.0 |
| Applicative (ST s)Source# | Since: 4.4.0.0 |
| Show (ST s a)Source# | Since: 2.1 |
| Semigroup a =>Semigroup (ST s a)Source# | Since: 4.11.0.0 |
| Monoid a =>Monoid (ST s a)Source# | Since: 4.11.0.0 |
runST :: (forall s.ST s a) -> aSource#
Return the value computed by a state transformer computation. Theforall ensures that the internal state used by theST computation is inaccessible to the rest of the program.
fixST :: (a ->ST s a) ->ST s aSource#
Allow the result of a state transformer computation to be used (lazily) inside the computation.
Note that iff is strict,.fixST f = _|_
ST toIORealWorld is deeply magical. It isprimitive, but it is notunlifted (henceptrArg). We never manipulate values of typeRealWorld; it's only used in the type system, to parameteriseState#.
Produced byHaddock version 2.20.0