-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A monad transformer version of the ST monad
--
-- A monad transformer version of the ST monad Warning! This monad
-- transformer should not be used with monads that can contain multiple
-- answers, like the list monad. The reason is that the will be
-- duplicated across the different answers and this cause Bad Things to
-- happen (such as loss of referential transparency). Safe monads include
-- the monads State, Reader, Writer, Maybe and combinations of their
-- corresponding monad transformers.
@package STMonadTrans
@version 0.3.2
-- | This module provides the implementation of the STT type for
-- those occasions where it's needed in order to implement new liftings
-- through operations in other monads.
--
-- Warning! This monad transformer should not be used with monads that
-- can contain multiple answers, like the list monad. The reason is that
-- the will be duplicated across the different answers and this cause Bad
-- Things to happen (such as loss of referential transparency). Safe
-- monads include the monads State, Reader, Writer, Maybe and
-- combinations of their corresponding monad transformers.
module Control.Monad.ST.Trans.Internal
-- | STT is the monad transformer providing polymorphic updateable
-- references
newtype STT s m a
STT :: (State# s -> m (STTRet s a)) -> STT s m a
unSTT :: STT s m a -> (State# s -> m (STTRet s a))
-- | STTRet is needed to encapsulate the unboxed state token that
-- GHC passes around. This type is essentially a pair, but an ordinary
-- pair is not not allowed to contain unboxed types.
data STTRet s a
STTRet :: (State# s) -> a -> STTRet s a
-- | This library provides a monad transformer version of the ST monad.
--
-- Warning! This monad transformer should not be used with monads that
-- can contain multiple answers, like the list monad. The reason is that
-- the will be duplicated across the different answers and this cause Bad
-- Things to happen (such as loss of referential transparency). Safe
-- monads include the monads State, Reader, Writer, Maybe and
-- combinations of their corresponding monad transformers.
module Control.Monad.ST.Trans
-- | STT is the monad transformer providing polymorphic updateable
-- references
data STT s m a
-- | Executes a computation in the STT monad transformer
runST :: Monad m => (forall s. STT s m a) -> m a
-- | Mutable references
data STRef s a
-- | Create a new reference
newSTRef :: Monad m => a -> STT s m (STRef s a)
-- | Reads the value of a reference
readSTRef :: Monad m => STRef s a -> STT s m a
-- | Modifies the value of a reference
writeSTRef :: Monad m => STRef s a -> a -> STT s m ()
-- | Mutable arrays
data STArray s i e
-- | Creates a new mutable array
newSTArray :: (Ix i, Monad m) => (i, i) -> e -> STT s m (STArray s i e)
-- | Retrieves an element from the array
readSTArray :: (Ix i, Monad m) => STArray s i e -> i -> STT s m e
-- | Modifies an element in the array
writeSTArray :: (Ix i, Monad m) => STArray s i e -> i -> e -> STT s m ()
-- | Returns the lowest and highest indices of the array
boundsSTArray :: STArray s i e -> (i, i)
-- | Returns the number of elements in the array
numElementsSTArray :: STArray s i e -> Int
-- | Copy a mutable array and turn it into an immutable array
freezeSTArray :: (Ix i, Monad m) => STArray s i e -> STT s m (Array i e)
-- | Copy an immutable array and turn it into a mutable array
thawSTArray :: (Ix i, Monad m) => Array i e -> STT s m (STArray s i e)
-- | A safe way to create and work with a mutable array before returning an
-- immutable array for later perusal. This function avoids copying the
-- array before returning it.
runSTArray :: (Ix i, Monad m) => (forall s. STT s m (STArray s i e)) -> m (Array i e)
unsafeIOToSTT :: Monad m => IO a -> STT s m a
unsafeSTToIO :: STT s IO a -> IO a
unsafeSTRefToIORef :: STRef s a -> IORef a
unsafeIORefToSTRef :: IORef a -> STRef s a
instance Eq (STArray s i e)
instance MonadWriter w m => MonadWriter w (STT s m)
instance MonadState s m => MonadState s (STT s' m)
instance MonadReader r m => MonadReader r (STT s m)
instance MonadError e m => MonadError e (STT s m)
instance Eq (STRef s a)
instance (Monad m, Functor m) => Applicative (STT s m)
instance Functor m => Functor (STT s m)
instance Functor (STTRet s)
instance MonadFix m => MonadFix (STT s m)
instance MonadTrans (STT s)
instance Monad m => Monad (STT s m)