primitive-0.7.4.0: Primitive memory-related operations
Copyright (c) Roman Leshchinskiy 2009
License BSD-style
Maintainer Roman Leshchinskiy <rl@cse.unsw.edu.au>
Portability non-portable
Safe Haskell None
Language Haskell2010

Control.Monad.Primitive

Description

Primitive state-transformer monads.

Synopsis

Documentation

class Monad m => PrimMonad m where Source #

Class of monads which can perform primitive state-transformer actions.

Associated Types

type PrimState m Source #

State token type.

Methods

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

Execute a primitive operation.

Instances

Instances details
PrimMonad IO Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState IO Source #

PrimMonad ( ST s) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( ST s) Source #

PrimMonad ( ST s) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( ST s) Source #

PrimMonad m => PrimMonad ( MaybeT m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( MaybeT m) Source #

PrimMonad m => PrimMonad ( ListT m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( ListT m) Source #

( Monoid w, PrimMonad m) => PrimMonad ( WriterT w m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( WriterT w m) Source #

( Monoid w, PrimMonad m) => PrimMonad ( AccumT w m) Source #

Since: 0.6.3.0

Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( AccumT w m) Source #

( Monoid w, PrimMonad m) => PrimMonad ( WriterT w m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( WriterT w m) Source #

( Monoid w, PrimMonad m) => PrimMonad ( WriterT w m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( WriterT w m) Source #

PrimMonad m => PrimMonad ( StateT s m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( StateT s m) Source #

PrimMonad m => PrimMonad ( StateT s m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( StateT s m) Source #

PrimMonad m => PrimMonad ( SelectT r m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( SelectT r m) Source #

PrimMonad m => PrimMonad ( ReaderT r m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( ReaderT r m) Source #

PrimMonad m => PrimMonad ( IdentityT m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( IdentityT m) Source #

PrimMonad m => PrimMonad ( ExceptT e m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( ExceptT e m) Source #

( Error e, PrimMonad m) => PrimMonad ( ErrorT e m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( ErrorT e m) Source #

PrimMonad m => PrimMonad ( ContT r m) Source #

Since: 0.6.3.0

Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( ContT r m) Source #

( Monoid w, PrimMonad m) => PrimMonad ( RWST r w s m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( RWST r w s m) Source #

Methods

primitive :: ( State# ( PrimState ( RWST r w s m)) -> (# State# ( PrimState ( RWST r w s m)), a #)) -> RWST r w s m a Source #

( Monoid w, PrimMonad m) => PrimMonad ( RWST r w s m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( RWST r w s m) Source #

Methods

primitive :: ( State# ( PrimState ( RWST r w s m)) -> (# State# ( PrimState ( RWST r w s m)), a #)) -> RWST r w s m a Source #

( Monoid w, PrimMonad m) => PrimMonad ( RWST r w s m) Source #
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState ( RWST r w s m) Source #

Methods

primitive :: ( State# ( PrimState ( RWST r w s m)) -> (# State# ( PrimState ( RWST r w s m)), a #)) -> RWST r w s m a Source #

data RealWorld Source #

RealWorld is deeply magical. It is primitive , but it is not unlifted (hence ptrArg ). We never manipulate values of type RealWorld ; it's only used in the type system, to parameterise State# .

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

Execute a primitive operation with no result.

class PrimMonad m => PrimBase m where Source #

Class of primitive monads for state-transformer actions.

Unlike PrimMonad , this typeclass requires that the Monad be fully expressed as a state transformer, therefore disallowing other monad transformers on top of the base IO or ST .

Since: 0.6.0.0

Methods

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

Expose the internal structure of the monad.

class ( PrimMonad m, s ~ PrimState m) => MonadPrim s m Source #

PrimMonad' s state token type can be annoying to handle in constraints. This typeclass lets users (visually) notice PrimState equality constraints less, by witnessing that s ~ PrimState m .

Instances

Instances details
( PrimMonad m, s ~ PrimState m) => MonadPrim s m Source #
Instance details

Defined in Control.Monad.Primitive

class ( PrimBase m, MonadPrim s m) => MonadPrimBase s m Source #

PrimBase' s state token type can be annoying to handle in constraints. This typeclass lets users (visually) notice PrimState equality constraints less, by witnessing that s ~ PrimState m .

Instances

Instances details
( PrimBase m, MonadPrim s m) => MonadPrimBase s m Source #
Instance details

Defined in Control.Monad.Primitive

liftPrim :: ( PrimBase m1, PrimMonad m2, PrimState m1 ~ PrimState m2) => m1 a -> m2 a Source #

Lifts a PrimBase into another PrimMonad with the same underlying state token type.

primToPrim :: ( PrimBase m1, PrimMonad m2, PrimState m1 ~ PrimState m2) => m1 a -> m2 a Source #

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

ioToPrim :: ( PrimMonad m, PrimState m ~ RealWorld ) => IO a -> m a Source #

Convert an IO action to a PrimMonad .

Since: 0.6.2.0

stToPrim :: PrimMonad m => ST ( PrimState m) a -> m a Source #

Convert an ST action to a PrimMonad .

Since: 0.6.2.0

unsafePrimToPrim :: ( PrimBase m1, PrimMonad m2) => m1 a -> m2 a Source #

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

unsafePrimToIO :: PrimBase m => m a -> IO a Source #

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

unsafePrimToST :: PrimBase m => m a -> ST s a Source #

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

unsafeIOToPrim :: PrimMonad m => IO a -> m a Source #

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

Since: 0.6.2.0

unsafeSTToPrim :: PrimMonad m => ST s a -> m a Source #

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

Since: 0.6.2.0

unsafeInlinePrim :: PrimBase m => m a -> a Source #

See unsafeInlineIO . This function is not recommended for the same reasons.

unsafeInlineIO :: IO a -> a Source #

Generally, do not use this function. It is the same as accursedUnutterablePerformIO from bytestring and is well behaved under narrow conditions. See the documentation of that function to get an idea of when this is sound. In most cases GHC.IO.Unsafe.unsafeDupablePerformIO should be preferred.

unsafeInlineST :: ST s a -> a Source #

See unsafeInlineIO . This function is not recommended for the same reasons. Prefer runST when s is free.

evalPrim :: forall a m. PrimMonad m => a -> m a Source #

Create an action to force a value; generalizes evaluate

Since: 0.6.2.0