This module contains the
MonadST type class, which encapsulates a monad capable of lifting an ST computation. This type class is only intended to be implemented by the
ST monad and any stack of monad transformers over an
Presence of a MonadST instance implies that
- The monad is single-threaded: performing an
STcomputation will not cause loss of referential transparency, and only one copy of its state thread will be available at any time.
- Monad transformers can demand an underlying
MonadSTinstance and use its state thread for their own safe computation in the
Note: Most monad type classes cannot pass instances up through any instance of
MonadTrans, because a transformer farther out may wish to override the inner instance. However, in
MonadST we very specifically only want one state thread for any stack of transformers, and specifically one at the very bottom level. This justifies the very general
MonadST propagation instance,
(MonadST m, MonadTrans t, Monad m, Monad (t m)) => MonadST (t m) (not shown in Haddock for unknown reasons).
Type class of monads that can perform lifted computation in the
The type of the state thread used in this monad, never actually instantiated.