STMonadTrans-0.4.7: A monad transformer version of the ST monad

Copyright | Josef Svenningsson 2008-2017 (c) The University of Glasgow 1994-2000
License | BSD
Maintainer | josef.svenningsson@gmail.com, Andreas Abel
Stability | stable
Portability | non-portable (GHC Extensions)
Safe Haskell | Safe-Inferred
Language | Haskell2010

Control.Monad.ST.Trans

Contents

- The ST Monad Transformer
- Mutable references
- Mutable arrays
- Unsafe Operations

Description

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.

Synopsis

- data STT s m a
- runST :: Monad m => (forall s. STT s m a) -> m a
- runSTT :: Monad m => (forall s. STT s m a) -> m a
- data STRef s a
- newSTRef :: Applicative m => a -> STT s m (STRef s a)
- readSTRef :: Applicative m => STRef s a -> STT s m a
- writeSTRef :: Applicative m => STRef s a -> a -> STT s m ()
- data STArray s i e
- newSTArray :: (Ix i, Applicative m) => (i, i) -> e -> STT s m (STArray s i e)
- readSTArray :: (Ix i, Applicative m) => STArray s i e -> i -> STT s m e
- writeSTArray :: (Ix i, Applicative m) => STArray s i e -> i -> e -> STT s m ()
- boundsSTArray :: STArray s i e -> (i, i)
- numElementsSTArray :: STArray s i e -> Int
- freezeSTArray :: Applicative m => STArray s i e -> STT s m (Array i e)
- thawSTArray :: Applicative m => Array i e -> STT s m (STArray s i e)
- runSTArray :: Monad m => (forall s. STT s m (STArray s i e)) -> m (Array i e)
- unsafeReadSTArray :: Applicative m => STArray s i e -> Int -> STT s m e
- unsafeWriteSTArray :: Applicative m => STArray s i e -> Int -> e -> STT s m ()
- unsafeFreezeSTArray :: Applicative m => STArray s i e -> STT s m (Array i e)
- unsafeThawSTArray :: Applicative m => Array i e -> STT s m (STArray s i e)
- unsafeIOToSTT :: (Monad m, Functor m) => IO a -> STT s m a
- 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

# The ST Monad Transformer

data STT s m a Source #

`STT` is the monad transformer providing polymorphic updateable references

#### Instances

Instances details

(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 Source # catchError :: STT s m a -> (e -> STT s m a) -> STT s m a Source #
(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 Source # local :: (r -> r) -> STT s m a -> STT s m a Source # reader :: (r -> a) -> STT s m a Source #
(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 Source # put :: s -> STT s1 m () Source # state :: (s -> (a, s)) -> STT s1 m a Source #
(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 Source # tell :: w -> STT s m () Source # listen :: STT s m a -> STT s m (a, w) Source # pass :: STT s m (a, w -> w) -> STT s m a Source #
MonadTrans (STT s) Source # |
Instance details Defined in Control.Monad.ST.Trans.Internal Methods lift :: Monad m => m a -> STT s m a Source #
(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) Source #

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

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

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

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) 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) Source #

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

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

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

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) 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) Source #

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

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

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

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) 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) Source #

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

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

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

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) 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) Source #

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

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

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

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) 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) Source #

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

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

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

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) 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) Source #

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

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

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

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) 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) Source #

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

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

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

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) 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) Source #

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

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

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

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 (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) Source #

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

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

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

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) 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) Source #

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

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

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

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) Source #

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

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

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

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) 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) Source #

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

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

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

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) 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) Source #

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

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

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

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 (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) Source #

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

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

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

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) (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) Source #

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)) Source #

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

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) Source #

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)) Source #

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

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 ()

(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) Source #

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)) Source #

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

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 ()

(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 Source #
(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 Source #
(MonadIO m, Functor m) => MonadIO (STT s m) Source # |
Instance details Defined in Control.Monad.ST.Trans.Internal Methods liftIO :: IO a -> STT s m a Source #
(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 Source # (<*>) :: STT s m (a -> b) -> STT s m a -> STT s m b Source # liftA2 :: (a -> b -> c) -> STT s m a -> STT s m b -> STT s m c Source # (*>) :: STT s m a -> STT s m b -> STT s m b Source # (<*) :: STT s m a -> STT s m b -> STT s m a Source #
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 Source # (<$) :: a -> STT s m b -> STT s m a Source #
(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 Source # (>>) :: STT s m a -> STT s m b -> STT s m b Source # return :: a -> STT s m a Source #

runST :: Monad m => (forall s. STT s m a) -> m a Source #

Deprecated: Use runSTT instead

Executes a computation in the `STT` monad transformer

runSTT :: Monad m => (forall s. STT s m a) -> m a Source #

Executes a computation in the `STT` monad transformer

# Mutable references

data STRef s a Source #

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"

#### Instances

Instances details

Eq (STRef s a) | Pointer equality. Since: base-2.1
Instance details Defined in GHC.STRef Methods (==) :: STRef s a -> STRef s a -> Bool Source # (/=) :: STRef s a -> STRef s a -> Bool Source #

newSTRef :: Applicative m => a -> STT s m (STRef s a) Source #

Create a new reference

readSTRef :: Applicative m => STRef s a -> STT s m a Source #

Reads the value of a reference

writeSTRef :: Applicative m => STRef s a -> a -> STT s m () Source #

Modifies the value of a reference

# Mutable arrays

data STArray s i e Source #

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.

#### Instances

Instances details

MArray (STArray s) e (ST s) |

Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STArray s i e -> ST s (i, i) Source #

getNumElements :: Ix i => STArray s i e -> ST s Int

newArray :: Ix i => (i, i) -> e -> ST s (STArray s i e) Source #

newArray_ :: Ix i => (i, i) -> ST s (STArray s i e) Source #

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

unsafeRead :: Ix i => STArray s i e -> Int -> ST s e

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

MArray (STArray s) e (ST s) |

Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STArray s i e -> ST s (i, i) Source #

getNumElements :: Ix i => STArray s i e -> ST s Int

newArray :: Ix i => (i, i) -> e -> ST s (STArray s i e) Source #

newArray_ :: Ix i => (i, i) -> ST s (STArray s i e) Source #

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

unsafeRead :: Ix i => STArray s i e -> Int -> ST s e

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

(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) Source #

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

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

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

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 ()

Eq (STArray s i e) | Since: base-2.1
Instance details Defined in GHC.Arr Methods (==) :: STArray s i e -> STArray s i e -> Bool Source # (/=) :: STArray s i e -> STArray s i e -> Bool Source #

newSTArray :: (Ix i, Applicative m) => (i, i) -> e -> STT s m (STArray s i e) Source #

Creates a new mutable array

readSTArray :: (Ix i, Applicative m) => STArray s i e -> i -> STT s m e Source #

Retrieves an element from the array

writeSTArray :: (Ix i, Applicative m) => STArray s i e -> i -> e -> STT s m () Source #

Modifies an element in the array

boundsSTArray :: STArray s i e -> (i, i) Source #

Returns the lowest and highest indices of the array

numElementsSTArray :: STArray s i e -> Int Source #

Returns the number of elements in the array

freezeSTArray :: Applicative m => STArray s i e -> STT s m (Array i e) Source #

Copy a mutable array and turn it into an immutable array

thawSTArray :: Applicative m => Array i e -> STT s m (STArray s i e) Source #

Copy an immutable array and turn it into a mutable array

runSTArray :: Monad m => (forall s. STT s m (STArray s i e)) -> m (Array i e) Source #

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.

# Unsafe Operations

unsafeReadSTArray :: Applicative m => STArray s i e -> Int -> STT s m e Source #

unsafeWriteSTArray :: Applicative m => STArray s i e -> Int -> e -> STT s m () Source #

unsafeFreezeSTArray :: Applicative m => STArray s i e -> STT s m (Array i e) Source #

unsafeThawSTArray :: Applicative m => Array i e -> STT s m (STArray s i e) Source #

unsafeIOToSTT :: (Monad m, Functor m) => IO a -> STT s m a Source #

unsafeSTToIO :: STT s IO a -> IO a Source #

Deprecated: Use unsafeSTTToIO instead

unsafeSTTToIO :: STT s IO a -> IO a Source #

unsafeSTRefToIORef :: STRef s a -> IORef a Source #

unsafeIORefToSTRef :: IORef a -> STRef s a Source #