Copyright | (c) Roman Leshchinskiy 2009 |
---|---|
License | BSD-style |
Maintainer | Roman Leshchinskiy <rl@cse.unsw.edu.au> |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Primitive state-transformer monads
- class Monad m => PrimMonad m where
- type PrimState m
- data RealWorld :: *
- primitive_ :: PrimMonad m => (State# (PrimState m) -> State# (PrimState m)) -> m ()
- class PrimMonad m => PrimBase m where
- liftPrim :: (PrimBase m1, PrimMonad m2, PrimState m1 ~ PrimState m2) => m1 a -> m2 a
- primToPrim :: (PrimBase m1, PrimMonad m2, PrimState m1 ~ PrimState m2) => m1 a -> m2 a
- primToIO :: (PrimBase m, PrimState m ~ RealWorld) => m a -> IO a
- primToST :: PrimBase m => m a -> ST (PrimState m) a
- ioToPrim :: (PrimMonad m, PrimState m ~ RealWorld) => IO a -> m a
- stToPrim :: PrimMonad m => ST (PrimState m) a -> m a
- unsafePrimToPrim :: (PrimBase m1, PrimMonad m2) => m1 a -> m2 a
- unsafePrimToIO :: PrimBase m => m a -> IO a
- unsafePrimToST :: PrimBase m => m a -> ST s a
- unsafeIOToPrim :: PrimMonad m => IO a -> m a
- unsafeSTToPrim :: PrimMonad m => ST s a -> m a
- unsafeInlinePrim :: PrimBase m => m a -> a
- unsafeInlineIO :: IO a -> a
- unsafeInlineST :: ST s a -> a
- touch :: PrimMonad m => a -> m ()
- evalPrim :: forall a m. PrimMonad m => a -> m a
Documentation
class Monad m => PrimMonad m where Source #
Class of monads which can perform primitive state-transformer actions
primitive :: (State# (PrimState m) -> (#State# (PrimState m), a#)) -> m a Source #
Execute a primitive operation
PrimMonad IO Source # | |
PrimMonad (ST s) Source # | |
PrimMonad m => PrimMonad (MaybeT m) Source # | |
PrimMonad m => PrimMonad (ListT m) Source # | |
(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) Source # | |
(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) Source # | |
PrimMonad m => PrimMonad (StateT s m) Source # | |
PrimMonad m => PrimMonad (StateT s m) Source # | |
PrimMonad m => PrimMonad (IdentityT * m) Source # | |
PrimMonad m => PrimMonad (ExceptT e m) Source # | |
(Error e, PrimMonad m) => PrimMonad (ErrorT e m) Source # | |
PrimMonad m => PrimMonad (ReaderT * r m) Source # | |
PrimMonad m => PrimMonad (ContT * r m) Source # | |
(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) Source # | |
(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) 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
.
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.
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 #
unsafePrimToST :: PrimBase m => m a -> ST s a Source #
unsafeIOToPrim :: PrimMonad m => IO a -> m a Source #
unsafeSTToPrim :: PrimMonad m => ST s a -> m a Source #
unsafeInlinePrim :: PrimBase m => m a -> a Source #
unsafeInlineIO :: IO a -> a Source #
unsafeInlineST :: ST s a -> a Source #