Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type MonadState s m = MonadStateN (Find (EffState s) m) s m
- get :: MonadState a m => m a
- put :: MonadState s m => s -> m ()
- modify :: MonadState s m => (s -> s) -> m ()
- modify' :: MonadState s m => (s -> s) -> m ()
- gets :: MonadState s m => (s -> a) -> m a
- type MonadReader e m = MonadReaderN (Find (EffReader e) m) e m
- type MonadLocal e m = MonadLocalN (Find (EffLocal e) m) e m
- ask :: forall m r. MonadReader r m => m r
- local :: forall a m r. MonadLocal r m => (r -> r) -> m a -> m a
- type MonadWriter w m = MonadWriterN (Find (EffWriter w) m) w m
- tell :: forall w m. MonadWriter w m => w -> m ()
- type MonadExcept e m = MonadExceptN (Find (EffExcept e) m) e m
- throw :: forall a e m. MonadExcept e m => e -> m a
- type MonadExec w m = MonadExecN (Find (EffExec w) m) w m
- exec :: forall w m a. MonadExec w m => w a -> m a
- class MonadLiftN n m where
- data EffWriter w
- data EffReader e
- data EffLocal e
- data EffState s
- data EffExec w
- data EffExcept e
- data Peano :: *
- class Monad m => MonadStateN n s m where
- class Monad m => MonadReaderN n r m where
- class Monad m => MonadLocalN n r m where
- class Monad m => MonadWriterN n w m where
- class Monad m => MonadExceptN n e m where
- class Monad m => MonadExecN n w m where
- type Find eff m = FindTrue (MapCanDo eff m)
- type family FindTrue bs :: Peano
- type family MapCanDo eff stack :: [Bool]
- type family CanDo m eff :: Bool
State
type MonadState s m = MonadStateN (Find (EffState s) m) s m Source
The
constraint asserts that MonadState
s mm
is a monad stack
that supports state operations on type s
get :: MonadState a m => m a Source
Fetch the current value of the state within the monad
put :: MonadState s m => s -> m () Source
sets the state within the monad to put
ss
modify :: MonadState s m => (s -> s) -> m () Source
Maps an old state to a new state inside a state monad layer
modify' :: MonadState s m => (s -> s) -> m () Source
A variant of modify
in which the computation is strict in the
new state
gets :: MonadState s m => (s -> a) -> m a Source
Gets specific component of the state, using a projection function supplied.
Reader
type MonadReader e m = MonadReaderN (Find (EffReader e) m) e m Source
The
constraint asserts that MonadReader
r mm
is a monad stack
that supports a fixed environment of type r
type MonadLocal e m = MonadLocalN (Find (EffLocal e) m) e m Source
The
constraint asserts that MonadLocal
r mm
is a monad stack
that supports a fixed environment of type r
that can be changed
externally to the monad
ask :: forall m r. MonadReader r m => m r Source
Fetch the environment passed through the reader monad
:: MonadLocal r m | |
=> (r -> r) | The function to modify the environment. |
-> m a |
|
-> m a |
Executes a computation in a modified environment.
Writer
type MonadWriter w m = MonadWriterN (Find (EffWriter w) m) w m Source
The
constraint asserts that MonadWriter
w mm
is a monad stack
that supports outputting values of type w
tell :: forall w m. MonadWriter w m => w -> m () Source
is an action that produces the output tell
ww
Exceptions
type MonadExcept e m = MonadExceptN (Find (EffExcept e) m) e m Source
The
constraint asserts that MonadExcept
e mm
is a monad stack
that supports throwing exceptions of type e
throw :: forall a e m. MonadExcept e m => e -> m a Source
Throw an exception
Exec
type MonadExec w m = MonadExecN (Find (EffExec w) m) w m Source
Core classes and types
Generic lifting
class MonadLiftN n m where Source
MonadLiftN Zero m | |
(MonadLiftN n m, MonadTrans t, Monad m) => MonadLiftN (Succ n) (t m) |
Effects
N-classes
data Peano :: *
class Monad m => MonadStateN n s m where Source
Monad m => MonadStateN Zero s (StateT s m) | |
Monad m => MonadStateN Zero s (StateT s m) | |
MonadState big m => MonadStateN Zero small (ZoomT * big small m) | |
(Monad (t m), MonadTrans t, MonadStateN n s m, Monad m) => MonadStateN (Succ n) s (t m) |
class Monad m => MonadReaderN n r m where Source
Monad m => MonadReaderN Zero r (StateT r m) | |
Monad m => MonadReaderN Zero r (StateT r m) | |
Monad m => MonadReaderN Zero r (ReaderT r m) | |
MonadReader big m => MonadReaderN Zero small (ZoomT * big small m) | |
(MonadTrans t, Monad (t m), MonadReaderN n r m, Monad m) => MonadReaderN (Succ n) r (t m) |
class Monad m => MonadLocalN n r m where Source
Monad m => MonadLocalN Zero r (StateT r m) | |
Monad m => MonadLocalN Zero r (StateT r m) | |
Monad m => MonadLocalN Zero r (ReaderT r m) | |
(MonadTrans t, Monad (t m), MFunctor t, MonadLocalN n r m, Monad m) => MonadLocalN (Succ n) r (t m) |
class Monad m => MonadWriterN n w m where Source
(Monad m, Monoid w) => MonadWriterN Zero w (StateT w m) | |
(Monad m, Monoid w) => MonadWriterN Zero w (StateT w m) | |
(Monad m, Monoid w) => MonadWriterN Zero w (WriterT w m) | |
(Monad m, Monoid w) => MonadWriterN Zero w (WriterT w m) | |
Monad m => MonadWriterN Zero w (CustomWriterT' * w m m) | |
(MonadState big m, Monoid small) => MonadWriterN Zero small (ZoomT * big small m) | |
(MonadTrans t, Monad (t m), MonadWriterN n w m, Monad m) => MonadWriterN (Succ n) w (t m) |
class Monad m => MonadExceptN n e m where Source
Exception e => MonadExceptN Zero e IO | |
Monad m => MonadExceptN Zero () (MaybeT m) | |
Monad m => MonadExceptN Zero e (ExceptT e m) | |
(MonadTrans t, Monad (t m), MonadExceptN n e m, Monad m) => MonadExceptN (Succ n) e (t m) |
class Monad m => MonadExecN n w m where Source
Monad w => MonadExecN Zero w w | |
(MonadTrans t, Monad (t m), MonadExecN n w m, Monad m) => MonadExecN (Succ n) w (t m) |
Type families
You should rarely need these. They are exported mostly for documentation and pedagogical purposes.
type Find eff m = FindTrue (MapCanDo eff m) Source
finds the first transformer in a monad transformer
stack that can handle the effect Find
eff meff
type family CanDo m eff :: Bool Source
describes whether the given effect can be performed in the
monad CanDo
m effm
(without any additional lifting)
type CanDo * IO (EffExcept e) = True | |
type CanDo * IO (EffExec IO) = True | |
type CanDo * (MaybeT m) eff | |
type CanDo * (WriterT w m) eff | |
type CanDo * (WriterT w m) eff | |
type CanDo * (ExceptT e m) eff | |
type CanDo * (StateT s m) eff | |
type CanDo * (StateT s m) eff | |
type CanDo * (ReaderT e m) eff | |
type CanDo * (CustomWriterT' * w n m) eff | |
type CanDo * (ZoomT * big small m) eff |