Copyright | (c) Alexey Kuleshevich 2020 |
---|---|
License | BSD3 |
Maintainer | Alexey Kuleshevich <alexey@kuleshevi.ch> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- type RW = RealWorld
- data RealWorld
- type MonadIO m = MonadPrim RW m
- class MonadThrow m => MonadPrim s m | m -> s where
- class MonadUnliftPrim s m => MonadPrimBase s m where
- type MonadUnliftIO m = MonadUnliftPrim RW m
- class MonadPrim s m => MonadUnliftPrim s m where
- withRunInST :: ((forall a. m a -> ST s a) -> ST s b) -> m b
- runInPrimBase1 :: (a -> m b) -> ((a -> State# s -> (# State# s, b #)) -> State# s -> (# State# s, c #)) -> m c
- runInPrimBase2 :: (a -> m b) -> (c -> m d) -> ((a -> State# s -> (# State# s, b #)) -> (c -> State# s -> (# State# s, d #)) -> State# s -> (# State# s, e #)) -> m e
- data ST s a
- unIO :: IO a -> State# RealWorld -> (# State# RealWorld, a #)
- unIO_ :: IO () -> State# RW -> State# RW
- unST :: ST s a -> State# s -> (# State# s, a #)
- unST_ :: ST s () -> State# s -> State# s
- runST :: (forall s. ST s a) -> a
- prim_ :: MonadPrim s m => (State# s -> State# s) -> m ()
- primBase_ :: MonadPrimBase s m => m () -> State# s -> State# s
- withRunInIO :: forall m b. MonadUnliftPrim RW m => ((forall a. m a -> IO a) -> IO b) -> m b
- withRunInPrimBase :: (MonadUnliftPrim s m, MonadPrimBase s n) => ((forall a. m a -> n a) -> n b) -> m b
- runInPrimBase :: forall s m a b. MonadUnliftPrim s m => m a -> ((State# s -> (# State# s, a #)) -> State# s -> (# State# s, b #)) -> m b
- liftIO :: MonadPrim RW m => IO a -> m a
- liftST :: MonadPrim s m => ST s a -> m a
- liftPrimBase :: (MonadPrimBase s n, MonadPrim s m) => n a -> m a
- primBaseToIO :: MonadPrimBase RealWorld m => m a -> IO a
- primBaseToST :: MonadPrimBase s m => m a -> ST s a
- eval :: MonadPrim s m => a -> m a
- evalM :: MonadPrim s m => m a -> m a
- class NFData a
- deepeval :: (MonadPrim s m, NFData a) => a -> m a
- deepevalM :: (MonadPrim s m, NFData a) => m a -> m a
- whenM :: Monad m => m Bool -> m () -> m ()
- unlessM :: Monad m => m Bool -> m () -> m ()
- module Control.Monad
Documentation
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#
.
Instances
MonadPrimBase RealWorld IO Source # | |
MonadUnliftPrim RealWorld IO Source # | |
Defined in Control.Prim.Monad.Internal withRunInST :: ((forall a. IO a -> ST RealWorld a) -> ST RealWorld b) -> IO b Source # runInPrimBase1 :: (a -> IO b) -> ((a -> State# RealWorld -> (# State# RealWorld, b #)) -> State# RealWorld -> (# State# RealWorld, c #)) -> IO c Source # runInPrimBase2 :: (a -> IO b) -> (c -> IO d) -> ((a -> State# RealWorld -> (# State# RealWorld, b #)) -> (c -> State# RealWorld -> (# State# RealWorld, d #)) -> State# RealWorld -> (# State# RealWorld, e #)) -> IO e Source # | |
MonadPrim RealWorld IO Source # | |
class MonadThrow m => MonadPrim s m | m -> s where Source #
Instances
MonadPrim RealWorld IO Source # | |
MonadPrim s m => MonadPrim s (MaybeT m) Source # | |
MonadPrim s (ST s) Source # | |
MonadPrim s m => MonadPrim s (WriterT w m) Source # | |
MonadPrim s m => MonadPrim s (SelectT r m) Source # | |
(Monoid w, MonadPrim s m) => MonadPrim s (AccumT w m) Source # | |
(Monoid w, MonadPrim s m) => MonadPrim s (WriterT w m) Source # | |
(Monoid w, MonadPrim s m) => MonadPrim s (WriterT w m) Source # | |
MonadPrim s m => MonadPrim s (StateT st m) Source # | |
MonadPrim s m => MonadPrim s (StateT st m) Source # | |
MonadPrim s m => MonadPrim s (ReaderT r m) Source # | |
MonadPrim s m => MonadPrim s (IdentityT m) Source # | |
(e ~ SomeException, MonadPrim s m) => MonadPrim s (ExceptT e m) Source # | |
MonadPrim s m => MonadPrim s (ContT r m) Source # | |
MonadPrim s m => MonadPrim s (RWST r w st m) Source # | |
(Monoid w, MonadPrim s m) => MonadPrim s (RWST r w st m) Source # | |
(Monoid w, MonadPrim s m) => MonadPrim s (RWST r w st m) Source # | |
class MonadUnliftPrim s m => MonadPrimBase s m where Source #
Instances
MonadPrimBase RealWorld IO Source # | |
MonadPrimBase s (ST s) Source # | |
MonadPrimBase s m => MonadPrimBase s (IdentityT m) Source # | |
type MonadUnliftIO m = MonadUnliftPrim RW m Source #
class MonadPrim s m => MonadUnliftPrim s m where Source #
withRunInST :: ((forall a. m a -> ST s a) -> ST s b) -> m b Source #
runInPrimBase1 :: (a -> m b) -> ((a -> State# s -> (# State# s, b #)) -> State# s -> (# State# s, c #)) -> m c Source #
runInPrimBase2 :: (a -> m b) -> (c -> m d) -> ((a -> State# s -> (# State# s, b #)) -> (c -> State# s -> (# State# s, d #)) -> State# s -> (# State# s, e #)) -> m e Source #
Instances
MonadUnliftPrim RealWorld IO Source # | |
Defined in Control.Prim.Monad.Internal withRunInST :: ((forall a. IO a -> ST RealWorld a) -> ST RealWorld b) -> IO b Source # runInPrimBase1 :: (a -> IO b) -> ((a -> State# RealWorld -> (# State# RealWorld, b #)) -> State# RealWorld -> (# State# RealWorld, c #)) -> IO c Source # runInPrimBase2 :: (a -> IO b) -> (c -> IO d) -> ((a -> State# RealWorld -> (# State# RealWorld, b #)) -> (c -> State# RealWorld -> (# State# RealWorld, d #)) -> State# RealWorld -> (# State# RealWorld, e #)) -> IO e Source # | |
MonadUnliftPrim s (ST s) Source # | |
Defined in Control.Prim.Monad.Internal withRunInST :: ((forall a. ST s a -> ST s a) -> ST s b) -> ST s b Source # runInPrimBase1 :: (a -> ST s b) -> ((a -> State# s -> (# State# s, b #)) -> State# s -> (# State# s, c #)) -> ST s c Source # runInPrimBase2 :: (a -> ST s b) -> (c -> ST s d) -> ((a -> State# s -> (# State# s, b #)) -> (c -> State# s -> (# State# s, d #)) -> State# s -> (# State# s, e #)) -> ST s e Source # | |
MonadUnliftPrim s m => MonadUnliftPrim s (ReaderT r m) Source # | |
Defined in Control.Prim.Monad.Internal withRunInST :: ((forall a. ReaderT r m a -> ST s a) -> ST s b) -> ReaderT r m b Source # runInPrimBase1 :: (a -> ReaderT r m b) -> ((a -> State# s -> (# State# s, b #)) -> State# s -> (# State# s, c #)) -> ReaderT r m c Source # runInPrimBase2 :: (a -> ReaderT r m b) -> (c -> ReaderT r m d) -> ((a -> State# s -> (# State# s, b #)) -> (c -> State# s -> (# State# s, d #)) -> State# s -> (# State# s, e #)) -> ReaderT r m e Source # | |
MonadUnliftPrim s m => MonadUnliftPrim s (IdentityT m) Source # | |
Defined in Control.Prim.Monad.Internal withRunInST :: ((forall a. IdentityT m a -> ST s a) -> ST s b) -> IdentityT m b Source # runInPrimBase1 :: (a -> IdentityT m b) -> ((a -> State# s -> (# State# s, b #)) -> State# s -> (# State# s, c #)) -> IdentityT m c Source # runInPrimBase2 :: (a -> IdentityT m b) -> (c -> IdentityT m d) -> ((a -> State# s -> (# State# s, b #)) -> (c -> State# s -> (# State# s, d #)) -> State# s -> (# State# s, e #)) -> IdentityT m e Source # |
The strict ST
monad.
The ST
monad allows for destructive updates, but is escapable (unlike IO).
A computation of type
returns a value of type ST
s aa
, and
execute in "thread" s
. The s
parameter is either
- an uninstantiated type variable (inside invocations of
runST
), or RealWorld
(inside invocations ofstToIO
).
It serves to keep the internal states of different invocations
of runST
separate from each other and from invocations of
stToIO
.
The >>=
and >>
operations are strict in the state (though not in
values stored in the state). For example,
runST
(writeSTRef _|_ v >>= f) = _|_
Instances
runST :: (forall s. ST s a) -> a #
Return the value computed by a state thread.
The forall
ensures that the internal state used by the ST
computation is inaccessible to the rest of the program.
prim_ :: MonadPrim s m => (State# s -> State# s) -> m () Source #
Construct a primitive action that does not return anything.
withRunInIO :: forall m b. MonadUnliftPrim RW m => ((forall a. m a -> IO a) -> IO b) -> m b Source #
withRunInPrimBase :: (MonadUnliftPrim s m, MonadPrimBase s n) => ((forall a. m a -> n a) -> n b) -> m b Source #
runInPrimBase :: forall s m a b. MonadUnliftPrim s m => m a -> ((State# s -> (# State# s, a #)) -> State# s -> (# State# s, b #)) -> m b Source #
liftIO :: MonadPrim RW m => IO a -> m a Source #
Lift an IO
action to MonadPrim
with the RealWorld
state token. Type restricted
synonym for liftPrimBase
liftST :: MonadPrim s m => ST s a -> m a Source #
Lift an ST
action to MonadPrim
with the same state token. Type restricted synonym
for liftPrimBase
liftPrimBase :: (MonadPrimBase s n, MonadPrim s m) => n a -> m a Source #
Lift an action from the MonadPrimBase
to another MonadPrim
with the same state
token.
primBaseToIO :: MonadPrimBase RealWorld m => m a -> IO a Source #
Restrict a MonadPrimBase
action that works with RealWorld
to IO
.
primBaseToST :: MonadPrimBase s m => m a -> ST s a Source #
Restrict a MonadPrimBase
action that works in ST
.
evalM :: MonadPrim s m => m a -> m a Source #
Run the action and then use eval
to ensure its result is evaluated to Weak Head
Normal Form (WHNF)
Since: 0.3.0
A class of types that can be fully evaluated.
Since: deepseq-1.1.0.0
Instances
NFData Bool | |
Defined in Control.DeepSeq | |
NFData Char | |
Defined in Control.DeepSeq | |
NFData Double | |
Defined in Control.DeepSeq | |
NFData Float | |
Defined in Control.DeepSeq | |
NFData Int | |
Defined in Control.DeepSeq | |
NFData Int8 | |
Defined in Control.DeepSeq | |
NFData Int16 | |
Defined in Control.DeepSeq | |
NFData Int32 | |
Defined in Control.DeepSeq | |
NFData Int64 | |
Defined in Control.DeepSeq | |
NFData Integer | |
Defined in Control.DeepSeq | |
NFData Natural | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData Ordering | |
Defined in Control.DeepSeq | |
NFData Word | |
Defined in Control.DeepSeq | |
NFData Word8 | |
Defined in Control.DeepSeq | |
NFData Word16 | |
Defined in Control.DeepSeq | |
NFData Word32 | |
Defined in Control.DeepSeq | |
NFData Word64 | |
Defined in Control.DeepSeq | |
NFData CallStack | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData () | |
Defined in Control.DeepSeq | |
NFData TyCon | NOTE: Prior to Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData Void | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData Unique | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData Version | Since: deepseq-1.3.0.0 |
Defined in Control.DeepSeq | |
NFData ThreadId | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData ExitCode | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData MaskingState | Since: deepseq-1.4.4.0 |
Defined in Control.DeepSeq rnf :: MaskingState -> () # | |
NFData TypeRep | NOTE: Prior to Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData All | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData Any | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CChar | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CSChar | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CUChar | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CShort | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CUShort | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CInt | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CUInt | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CLong | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CULong | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CLLong | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CULLong | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CBool | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
NFData CFloat | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CDouble | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CPtrdiff | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CSize | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CWchar | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CSigAtomic | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq rnf :: CSigAtomic -> () # | |
NFData CClock | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CTime | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CUSeconds | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CSUSeconds | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq rnf :: CSUSeconds -> () # | |
NFData CFile | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CFpos | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CJmpBuf | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CIntPtr | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CUIntPtr | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CIntMax | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData CUIntMax | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData Fingerprint | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq rnf :: Fingerprint -> () # | |
NFData SrcLoc | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData a => NFData [a] | |
Defined in Control.DeepSeq | |
NFData a => NFData (Maybe a) | |
Defined in Control.DeepSeq | |
NFData a => NFData (Ratio a) | |
Defined in Control.DeepSeq | |
NFData (StablePtr a) Source # | |
Defined in Foreign.Prim.StablePtr | |
NFData (Ptr a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData (FunPtr a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Complex a) | |
Defined in Control.DeepSeq | |
NFData a => NFData (Min a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Max a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (First a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Last a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData m => NFData (WrappedMonoid m) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq rnf :: WrappedMonoid m -> () # | |
NFData a => NFData (Option a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData (StableName a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq rnf :: StableName a -> () # | |
NFData a => NFData (ZipList a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Identity a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData (IORef a) | NOTE: Only strict in the reference and not the referenced value. Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (First a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Last a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Dual a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Sum a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Product a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (Down a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData (MVar a) | NOTE: Only strict in the reference and not the referenced value. Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData a => NFData (NonEmpty a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData (BNF a) Source # | Unlawful instance that only evaluates its contents to WHNF Since: 0.3.0 |
Defined in Control.Prim.Eval | |
NFData a => NFData (Atom a) Source # | |
Defined in Data.Prim.Atom | |
NFData (Off e) Source # | |
NFData (Count e) Source # | |
NFData (UArray e) Source # | O(1) - |
Defined in Data.Prim.Array | |
NFData e => NFData (SBArray e) Source # | |
Defined in Data.Prim.Array | |
NFData e => NFData (BArray e) Source # | |
Defined in Data.Prim.Array | |
NFData (a -> b) | This instance is for convenience and consistency with Since: deepseq-1.3.0.0 |
Defined in Control.DeepSeq | |
(NFData a, NFData b) => NFData (Either a b) | |
Defined in Control.DeepSeq | |
(NFData a, NFData b) => NFData (a, b) | |
Defined in Control.DeepSeq | |
(NFData a, NFData b) => NFData (Array a b) | |
Defined in Control.DeepSeq | |
NFData (Fixed a) | Since: deepseq-1.3.0.0 |
Defined in Control.DeepSeq | |
(NFData a, NFData b) => NFData (Arg a b) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData (Proxy a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData (STRef s a) | NOTE: Only strict in the reference and not the referenced value. Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
NFData (UMArray e s) Source # | O(1) - |
Defined in Data.Prim.Array | |
(NFData a1, NFData a2, NFData a3) => NFData (a1, a2, a3) | |
Defined in Control.DeepSeq | |
NFData a => NFData (Const a b) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
NFData (a :~: b) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
(NFData a1, NFData a2, NFData a3, NFData a4) => NFData (a1, a2, a3, a4) | |
Defined in Control.DeepSeq | |
(NFData1 f, NFData1 g, NFData a) => NFData (Product f g a) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
(NFData1 f, NFData1 g, NFData a) => NFData (Sum f g a) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
NFData (a :~~: b) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5) => NFData (a1, a2, a3, a4, a5) | |
Defined in Control.DeepSeq | |
(NFData1 f, NFData1 g, NFData a) => NFData (Compose f g a) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6) => NFData (a1, a2, a3, a4, a5, a6) | |
Defined in Control.DeepSeq | |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7) => NFData (a1, a2, a3, a4, a5, a6, a7) | |
Defined in Control.DeepSeq | |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8) => NFData (a1, a2, a3, a4, a5, a6, a7, a8) | |
Defined in Control.DeepSeq | |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8, NFData a9) => NFData (a1, a2, a3, a4, a5, a6, a7, a8, a9) | |
Defined in Control.DeepSeq |
deepeval :: (MonadPrim s m, NFData a) => a -> m a Source #
An action that evaluates a value to Normal Form (NF). This function provides stronger
guarantees than deepseq
with respect to ordering of operations.
Since: 0.3.0
deepevalM :: (MonadPrim s m, NFData a) => m a -> m a Source #
Run the action and the using deepeval
ensure its result is evaluated to Normal Form
(NF)
Since: 0.3.0
whenM :: Monad m => m Bool -> m () -> m () Source #
Similar to when
, but condional is supplied in a form of monadic action rather than a
pure value.
Since: 0.3.0
unlessM :: Monad m => m Bool -> m () -> m () Source #
Similar to unless
, but condional is supplied in a form of monadic action rather than a
pure value.
Since: 0.3.0
Re-export
module Control.Monad