primitive-0.5.0.1: Primitive memory-related operations

Portabilitynon-portable
MaintainerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Safe HaskellNone

Control.Monad.Primitive

Description

Primitive state-transformer monads

Synopsis

Documentation

class Monad m => PrimMonad m whereSource

Class of primitive state-transformer monads

Associated Types

type PrimState m Source

State token type

Methods

primitive :: (State# (PrimState m) -> (#State# (PrimState m), a#)) -> m aSource

Execute a primitive operation

internal :: m a -> State# (PrimState m) -> (#State# (PrimState m), a#)Source

Expose the internal structure of the monad

Instances

PrimMonad IO 
PrimMonad (ST s) 

data RealWorld

Instances

Typeable RealWorld 

primitive_ :: PrimMonad m => (State# (PrimState m) -> State# (PrimState m)) -> m ()Source

Execute a primitive operation with no result

primToPrim :: (PrimMonad m1, PrimMonad m2, PrimState m1 ~ PrimState m2) => m1 a -> m2 aSource

Convert a PrimMonad to another monad with the same state token.

primToIO :: (PrimMonad m, PrimState m ~ RealWorld) => m a -> IO aSource

Convert a PrimMonad with a RealWorld state token to IO

primToST :: PrimMonad m => m a -> ST (PrimState m) aSource

Convert a PrimMonad to ST

unsafePrimToPrim :: (PrimMonad m1, PrimMonad m2) => m1 a -> m2 aSource

Convert a PrimMonad to another monad with a possibly different state token. This operation is highly unsafe!

unsafePrimToIO :: PrimMonad m => m a -> IO aSource

Convert any PrimMonad to IO. This operation is highly unsafe!

unsafePrimToST :: PrimMonad m => m a -> ST s aSource

Convert any PrimMonad to ST with an arbitrary state token. This operation is highly unsafe!

unsafeInlineST :: ST s a -> aSource

touch :: PrimMonad m => a -> m ()Source