-- 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 state token will be duplicated across the different answers and
--   this causes 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.4.8.1

-- | This module provides the implementation of the STT type for
--   those occasions where it is 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 :: Type -> Type) a
STT :: (State# s -> m (STTRet s a)) -> STT s (m :: Type -> Type) 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

-- | Lifting the ST monad into STT. The library uses this
--   function extensively to be able to reuse functions from ST.
liftST :: forall (m :: Type -> Type) s a. Applicative m => ST s a -> STT s m a
liftSTT :: STT s m a -> State# s -> m (STTRet s a)
instance (GHC.Internal.Base.Monad m, GHC.Internal.Base.Alternative m) => GHC.Internal.Base.Alternative (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Monad m, GHC.Internal.Base.Functor m) => GHC.Internal.Base.Applicative (Control.Monad.ST.Trans.Internal.STT s m)
instance GHC.Internal.Base.Functor m => GHC.Internal.Base.Functor (Control.Monad.ST.Trans.Internal.STT s m)
instance GHC.Internal.Base.Functor (Control.Monad.ST.Trans.Internal.STTRet s)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (GHC.Internal.Arr.STArray s) e (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Types.Bool (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Types.Char (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Types.Double (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Types.Float (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) (GHC.Internal.Ptr.FunPtr a) (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Internal.Int.Int16 (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Internal.Int.Int32 (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Internal.Int.Int64 (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Internal.Int.Int8 (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Types.Int (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) (GHC.Internal.Ptr.Ptr a) (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) (GHC.Internal.Stable.StablePtr a) (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Internal.Word.Word16 (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Internal.Word.Word32 (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Internal.Word.Word64 (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Internal.Word.Word8 (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Applicative m, GHC.Internal.Base.Monad m) => Data.Array.Base.MArray (Data.Array.Base.STUArray s) GHC.Types.Word (Control.Monad.ST.Trans.Internal.STT s m)
instance (Control.Monad.Error.Class.MonadError e m, GHC.Internal.Base.Functor m) => Control.Monad.Error.Class.MonadError e (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Control.Monad.Fail.MonadFail m, GHC.Internal.Base.Functor m) => GHC.Internal.Control.Monad.Fail.MonadFail (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Control.Monad.Fix.MonadFix m, GHC.Internal.Base.Functor m) => GHC.Internal.Control.Monad.Fix.MonadFix (Control.Monad.ST.Trans.Internal.STT s m)
instance (Control.Monad.IO.Class.MonadIO m, GHC.Internal.Base.Functor m) => Control.Monad.IO.Class.MonadIO (Control.Monad.ST.Trans.Internal.STT s m)
instance (Control.Monad.Reader.Class.MonadReader r m, GHC.Internal.Base.Functor m) => Control.Monad.Reader.Class.MonadReader r (Control.Monad.ST.Trans.Internal.STT s m)
instance (GHC.Internal.Base.Monad m, GHC.Internal.Base.Functor m) => GHC.Internal.Base.Monad (Control.Monad.ST.Trans.Internal.STT s m)
instance (Control.Monad.State.Class.MonadState s m, GHC.Internal.Base.Functor m) => Control.Monad.State.Class.MonadState s (Control.Monad.ST.Trans.Internal.STT s1 m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.ST.Trans.Internal.STT s)
instance (Control.Monad.Writer.Class.MonadWriter w m, GHC.Internal.Base.Functor m) => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.ST.Trans.Internal.STT s m)

-- | 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 state token will be duplicated across the different answers and
--   this causes 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 :: Type -> Type) a

-- | Executes a computation in the STT monad transformer

-- | Deprecated: Use runSTT instead
runST :: Monad m => (forall s. () => STT s m a) -> m a

-- | Executes a computation in the STT monad transformer
runSTT :: Monad m => (forall s. () => STT s m a) -> m a

-- | a value of type STRef s a is a mutable variable in state
--   thread s, containing a value of type a
--   
--   
--   >>> :{
--   runST (do
--       ref <- newSTRef "hello"
--       x <- readSTRef ref
--       writeSTRef ref (x ++ "world")
--       readSTRef ref )
--   :}
--   "helloworld"
--   
data STRef s a

-- | Create a new reference
newSTRef :: forall (m :: Type -> Type) a s. Applicative m => a -> STT s m (STRef s a)

-- | Reads the value of a reference
readSTRef :: forall (m :: Type -> Type) s a. Applicative m => STRef s a -> STT s m a

-- | Modifies the value of a reference
writeSTRef :: forall (m :: Type -> Type) s a. Applicative m => STRef s a -> a -> STT s m ()

-- | Mutable, boxed, non-strict arrays in the ST monad. The type
--   arguments are as follows:
--   
--   
--   
- s: the state variable argument for the ST
--   type
--   
- i: the index type of the array (should be an instance of
--   Ix)
--   
- e: the element type of the array.
--   
data STArray s i e

-- | Creates a new mutable array
newSTArray :: forall i (m :: Type -> Type) e s. (Ix i, Applicative m) => (i, i) -> e -> STT s m (STArray s i e)

-- | Retrieves an element from the array
readSTArray :: forall i (m :: Type -> Type) s e. (Ix i, Applicative m) => STArray s i e -> i -> STT s m e

-- | Modifies an element in the array
writeSTArray :: forall i (m :: Type -> Type) s e. (Ix i, Applicative 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 :: forall (m :: Type -> Type) s i e. Applicative m => STArray s i e -> STT s m (Array i e)

-- | Copy an immutable array and turn it into a mutable array
thawSTArray :: forall (m :: Type -> Type) i e s. Applicative 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 :: Monad m => (forall s. () => STT s m (STArray s i e)) -> m (Array i e)
unsafeReadSTArray :: forall (m :: Type -> Type) s i e. Applicative m => STArray s i e -> Int -> STT s m e
unsafeWriteSTArray :: forall (m :: Type -> Type) s i e. Applicative m => STArray s i e -> Int -> e -> STT s m ()
unsafeFreezeSTArray :: forall (m :: Type -> Type) s i e. Applicative m => STArray s i e -> STT s m (Array i e)
unsafeThawSTArray :: forall (m :: Type -> Type) i e s. Applicative m => Array i e -> STT s m (STArray s i e)
unsafeIOToSTT :: forall (m :: Type -> Type) a s. (Monad m, Functor m) => IO a -> STT s m a

-- | Deprecated: Use unsafeSTTToIO instead
unsafeSTToIO :: STT s IO a -> IO a
unsafeSTTToIO :: STT s IO a -> IO a
unsafeSTRefToIORef :: STRef s a -> IORef a
unsafeIORefToSTRef :: IORef a -> STRef s a
