Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type MonadState s m = MonadStateN (Find (EffState s) m) s m
- state :: forall s m a. MonadState s m => (s -> (a, s)) -> m a
- 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 :: Peano) 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 :: Peano) s m where
- class Monad m => MonadReaderN (n :: Peano) r m where
- class Monad m => MonadLocalN (n :: Peano) r m where
- class Monad m => MonadWriterN (n :: Peano) w m where
- class Monad m => MonadExceptN (n :: Peano) e m where
- class Monad m => MonadExecN (n :: Peano) w m where
- type Find eff (m :: * -> *) = FindTrue (MapCanDo eff m)
- type family FindTrue (bs :: [Bool]) :: Peano where ...
- type family MapCanDo (eff :: k) (stack :: * -> *) :: [Bool] where ...
- type family CanDo (m :: * -> *) (eff :: k) :: 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
state :: forall s m a. MonadState s m => (s -> (a, s)) -> m a Source #
Construct a state monad computation from a function
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
Core classes and types
Generic lifting
class MonadLiftN (n :: Peano) m where Source #
MonadLiftN Zero m Source # | |
(MonadLiftN n m, MonadTrans t, Monad m) => MonadLiftN (Succ n) (t m) Source # | |
Effects
N-classes
class Monad m => MonadStateN (n :: Peano) s m where Source #
Monad m => MonadStateN Zero s (StateT s m) Source # | |
Monad m => MonadStateN Zero s (StateT s m) Source # | |
MonadState big m => MonadStateN Zero small (ZoomT * big small m) Source # | |
(Monad (t m), MonadTrans t, MonadStateN n s m, Monad m) => MonadStateN (Succ n) s (t m) Source # | |
class Monad m => MonadReaderN (n :: Peano) r m where Source #
Monad m => MonadReaderN Zero r (StateT r m) Source # | |
Monad m => MonadReaderN Zero r (StateT r m) Source # | |
MonadReaderN Zero r ((->) LiftedRep LiftedRep r) Source # | |
Monad m => MonadReaderN Zero r (ReaderT * r m) Source # | |
MonadState s m => MonadReaderN Zero s (ReadStateT * * s m) Source # | |
MonadReader big m => MonadReaderN Zero small (ZoomT * big small m) Source # | |
(MonadTrans t, Monad (t m), MonadReaderN n r m, Monad m) => MonadReaderN (Succ n) r (t m) Source # | |
class Monad m => MonadLocalN (n :: Peano) r m where Source #
Monad m => MonadLocalN Zero r (StateT r m) Source # | |
Monad m => MonadLocalN Zero r (StateT r m) Source # | |
MonadLocalN Zero r ((->) LiftedRep LiftedRep r) Source # | |
Monad m => MonadLocalN Zero r (ReaderT * r m) Source # | |
(MonadTrans t, Monad (t m), MFunctor * t, MonadLocalN n r m, Monad m) => MonadLocalN (Succ n) r (t m) Source # | |
class Monad m => MonadWriterN (n :: Peano) w m where Source #
(Monad m, Monoid w) => MonadWriterN Zero w (StateT w m) Source # | |
(Monad m, Monoid w) => MonadWriterN Zero w (StateT w m) Source # | |
(Monad m, Monoid w) => MonadWriterN Zero w (WriterT w m) Source # | |
(Monad m, Monoid w) => MonadWriterN Zero w (WriterT w m) Source # | |
Monad m => MonadWriterN Zero w (CustomWriterT' * w m m) Source # | |
(MonadState big m, Monoid small) => MonadWriterN Zero small (ZoomT * big small m) Source # | |
(MonadTrans t, Monad (t m), MonadWriterN n w m, Monad m) => MonadWriterN (Succ n) w (t m) Source # | |
class Monad m => MonadExceptN (n :: Peano) e m where Source #
Exception e => MonadExceptN Zero e IO Source # | |
Monad m => MonadExceptN Zero () (MaybeT m) Source # | |
Monad m => MonadExceptN Zero e (ExceptT e m) Source # | |
(MonadTrans t, Monad (t m), MonadExceptN n e m, Monad m) => MonadExceptN (Succ n) e (t m) Source # | |
class Monad m => MonadExecN (n :: Peano) w m where Source #
Monad w => MonadExecN Zero w w Source # | |
(MonadTrans t, Monad (t m), MonadExecN n w m, Monad m) => MonadExecN (Succ n) w (t m) Source # | |
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 MapCanDo (eff :: k) (stack :: * -> *) :: [Bool] where ... Source #
type family CanDo (m :: * -> *) (eff :: k) :: 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) Source # | |
type CanDo * IO (EffExec IO) Source # | |
type CanDo * (MaybeT m) eff Source # | |
type CanDo * (WriterT w m) eff Source # | |
type CanDo * (StateT s m) eff Source # | |
type CanDo * (ExceptT e m) eff Source # | |
type CanDo * (StateT s m) eff Source # | |
type CanDo * (WriterT w m) eff Source # | |
type CanDo * ((->) LiftedRep LiftedRep e) eff Source # | |
type CanDo * (ReaderT * e m) eff Source # | |
type CanDo * (ReadStateT * * s m) eff Source # | |
type CanDo * (CustomWriterT' * w n m) eff Source # | |
type CanDo * (ZoomT * big small m) eff Source # | |