STMonadTrans-0.4.6: A monad transformer version of the ST monad
CopyrightJosef Svenningsson 2008-2010
(c) The University of Glasgow 1994-2000
LicenseBSD
Maintainerjosef.svenningsson@gmail.com, Andreas Abel
Stabilitystable
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone
LanguageHaskell2010

Control.Monad.ST.Trans.Internal

Description

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.

Synopsis

Documentation

newtype STT s m a Source #

STT is the monad transformer providing polymorphic updateable references

Constructors

STT (State# s -> m (STTRet s a)) 

Instances

Instances details
(MonadWriter w m, Functor m) => MonadWriter w (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

writer :: (a, w) -> STT s m a #

tell :: w -> STT s m () #

listen :: STT s m a -> STT s m (a, w) #

pass :: STT s m (a, w -> w) -> STT s m a #

(MonadState s m, Functor m) => MonadState s (STT s1 m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

get :: STT s1 m s #

put :: s -> STT s1 m () #

state :: (s -> (a, s)) -> STT s1 m a #

(MonadReader r m, Functor m) => MonadReader r (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

ask :: STT s m r #

local :: (r -> r) -> STT s m a -> STT s m a #

reader :: (r -> a) -> STT s m a #

(MonadError e m, Functor m) => MonadError e (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

throwError :: e -> STT s m a #

catchError :: STT s m a -> (e -> STT s m a) -> STT s m a #

MonadTrans (STT s) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

lift :: Monad m => m a -> STT s m a #

(Applicative m, Monad m) => MArray (STUArray s) Word64 (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Word64 -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Word64 -> STT s m Int

newArray :: Ix i => (i, i) -> Word64 -> STT s m (STUArray s i Word64) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word64) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word64)

unsafeRead :: Ix i => STUArray s i Word64 -> Int -> STT s m Word64

unsafeWrite :: Ix i => STUArray s i Word64 -> Int -> Word64 -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Word32 (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Word32 -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Word32 -> STT s m Int

newArray :: Ix i => (i, i) -> Word32 -> STT s m (STUArray s i Word32) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word32) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word32)

unsafeRead :: Ix i => STUArray s i Word32 -> Int -> STT s m Word32

unsafeWrite :: Ix i => STUArray s i Word32 -> Int -> Word32 -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Word16 (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Word16 -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Word16 -> STT s m Int

newArray :: Ix i => (i, i) -> Word16 -> STT s m (STUArray s i Word16) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word16) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word16)

unsafeRead :: Ix i => STUArray s i Word16 -> Int -> STT s m Word16

unsafeWrite :: Ix i => STUArray s i Word16 -> Int -> Word16 -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Word8 (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Word8 -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Word8 -> STT s m Int

newArray :: Ix i => (i, i) -> Word8 -> STT s m (STUArray s i Word8) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word8) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word8)

unsafeRead :: Ix i => STUArray s i Word8 -> Int -> STT s m Word8

unsafeWrite :: Ix i => STUArray s i Word8 -> Int -> Word8 -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Int64 (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Int64 -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Int64 -> STT s m Int

newArray :: Ix i => (i, i) -> Int64 -> STT s m (STUArray s i Int64) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int64) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int64)

unsafeRead :: Ix i => STUArray s i Int64 -> Int -> STT s m Int64

unsafeWrite :: Ix i => STUArray s i Int64 -> Int -> Int64 -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Int32 (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Int32 -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Int32 -> STT s m Int

newArray :: Ix i => (i, i) -> Int32 -> STT s m (STUArray s i Int32) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int32) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int32)

unsafeRead :: Ix i => STUArray s i Int32 -> Int -> STT s m Int32

unsafeWrite :: Ix i => STUArray s i Int32 -> Int -> Int32 -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Int16 (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Int16 -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Int16 -> STT s m Int

newArray :: Ix i => (i, i) -> Int16 -> STT s m (STUArray s i Int16) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int16) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int16)

unsafeRead :: Ix i => STUArray s i Int16 -> Int -> STT s m Int16

unsafeWrite :: Ix i => STUArray s i Int16 -> Int -> Int16 -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Int8 (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Int8 -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Int8 -> STT s m Int

newArray :: Ix i => (i, i) -> Int8 -> STT s m (STUArray s i Int8) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int8) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int8)

unsafeRead :: Ix i => STUArray s i Int8 -> Int -> STT s m Int8

unsafeWrite :: Ix i => STUArray s i Int8 -> Int -> Int8 -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Double (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Double -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Double -> STT s m Int

newArray :: Ix i => (i, i) -> Double -> STT s m (STUArray s i Double) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Double) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Double)

unsafeRead :: Ix i => STUArray s i Double -> Int -> STT s m Double

unsafeWrite :: Ix i => STUArray s i Double -> Int -> Double -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Float (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Float -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Float -> STT s m Int

newArray :: Ix i => (i, i) -> Float -> STT s m (STUArray s i Float) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Float) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Float)

unsafeRead :: Ix i => STUArray s i Float -> Int -> STT s m Float

unsafeWrite :: Ix i => STUArray s i Float -> Int -> Float -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Word (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Word -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Word -> STT s m Int

newArray :: Ix i => (i, i) -> Word -> STT s m (STUArray s i Word) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Word)

unsafeRead :: Ix i => STUArray s i Word -> Int -> STT s m Word

unsafeWrite :: Ix i => STUArray s i Word -> Int -> Word -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Int (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Int -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Int -> STT s m Int

newArray :: Ix i => (i, i) -> Int -> STT s m (STUArray s i Int) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Int)

unsafeRead :: Ix i => STUArray s i Int -> Int -> STT s m Int

unsafeWrite :: Ix i => STUArray s i Int -> Int -> Int -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Char (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Char -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Char -> STT s m Int

newArray :: Ix i => (i, i) -> Char -> STT s m (STUArray s i Char) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Char) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Char)

unsafeRead :: Ix i => STUArray s i Char -> Int -> STT s m Char

unsafeWrite :: Ix i => STUArray s i Char -> Int -> Char -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) Bool (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i Bool -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i Bool -> STT s m Int

newArray :: Ix i => (i, i) -> Bool -> STT s m (STUArray s i Bool) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Bool) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i Bool)

unsafeRead :: Ix i => STUArray s i Bool -> Int -> STT s m Bool

unsafeWrite :: Ix i => STUArray s i Bool -> Int -> Bool -> STT s m ()

(Applicative m, Monad m) => MArray (STArray s) e (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STArray s i e -> STT s m (i, i) #

getNumElements :: Ix i => STArray s i e -> STT s m Int

newArray :: Ix i => (i, i) -> e -> STT s m (STArray s i e) #

newArray_ :: Ix i => (i, i) -> STT s m (STArray s i e) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STArray s i e)

unsafeRead :: Ix i => STArray s i e -> Int -> STT s m e

unsafeWrite :: Ix i => STArray s i e -> Int -> e -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) (StablePtr a) (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i (StablePtr a) -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i (StablePtr a) -> STT s m Int

newArray :: Ix i => (i, i) -> StablePtr a -> STT s m (STUArray s i (StablePtr a)) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i (StablePtr a)) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i (StablePtr a))

unsafeRead :: Ix i => STUArray s i (StablePtr a) -> Int -> STT s m (StablePtr a)

unsafeWrite :: Ix i => STUArray s i (StablePtr a) -> Int -> StablePtr a -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) (FunPtr a) (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i (FunPtr a) -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i (FunPtr a) -> STT s m Int

newArray :: Ix i => (i, i) -> FunPtr a -> STT s m (STUArray s i (FunPtr a)) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i (FunPtr a)) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i (FunPtr a))

unsafeRead :: Ix i => STUArray s i (FunPtr a) -> Int -> STT s m (FunPtr a)

unsafeWrite :: Ix i => STUArray s i (FunPtr a) -> Int -> FunPtr a -> STT s m ()

(Applicative m, Monad m) => MArray (STUArray s) (Ptr a) (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

getBounds :: Ix i => STUArray s i (Ptr a) -> STT s m (i, i) #

getNumElements :: Ix i => STUArray s i (Ptr a) -> STT s m Int

newArray :: Ix i => (i, i) -> Ptr a -> STT s m (STUArray s i (Ptr a)) #

newArray_ :: Ix i => (i, i) -> STT s m (STUArray s i (Ptr a)) #

unsafeNewArray_ :: Ix i => (i, i) -> STT s m (STUArray s i (Ptr a))

unsafeRead :: Ix i => STUArray s i (Ptr a) -> Int -> STT s m (Ptr a)

unsafeWrite :: Ix i => STUArray s i (Ptr a) -> Int -> Ptr a -> STT s m ()

(Monad m, Functor m) => Monad (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

(>>=) :: STT s m a -> (a -> STT s m b) -> STT s m b #

(>>) :: STT s m a -> STT s m b -> STT s m b #

return :: a -> STT s m a #

Functor m => Functor (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

fmap :: (a -> b) -> STT s m a -> STT s m b #

(<$) :: a -> STT s m b -> STT s m a #

(MonadFix m, Functor m) => MonadFix (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

mfix :: (a -> STT s m a) -> STT s m a #

(MonadFail m, Functor m) => MonadFail (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

fail :: String -> STT s m a #

(Monad m, Functor m) => Applicative (STT s m) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

pure :: a -> STT s m a #

(<*>) :: STT s m (a -> b) -> STT s m a -> STT s m b #

liftA2 :: (a -> b -> c) -> STT s m a -> STT s m b -> STT s m c #

(*>) :: STT s m a -> STT s m b -> STT s m b #

(<*) :: STT s m a -> STT s m b -> STT s m a #

unSTT :: STT s m a -> State# s -> m (STTRet s a) Source #

data STTRet s a Source #

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.

Constructors

STTRet (State# s) a 

Instances

Instances details
Functor (STTRet s) Source # 
Instance details

Defined in Control.Monad.ST.Trans.Internal

Methods

fmap :: (a -> b) -> STTRet s a -> STTRet s b #

(<$) :: a -> STTRet s b -> STTRet s a #

liftST :: Applicative m => ST s a -> STT s m a Source #

Lifting the ST monad into STT. The library uses this function extensively to be able to reuse functions from ST.

liftSTT :: STT s m a -> State# s -> m (STTRet s a) Source #