Copyright | (c) Michael Szvetits 2020 |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | typedbyte@qualified.name |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
The effect that combines the reader, writer and state effect, similar to the
MonadRWS
type class from the mtl
library.
Lazy and strict interpretations of the effect are available here: Control.Effect.RWS.Lazy and Control.Effect.RWS.Strict.
Synopsis
- class (Reader' tag r m, Writer' tag w m, State' tag s m) => RWS' tag r w s m | tag m -> r w s
- type RWS r w s = RWS' G r w s
- data Separation m a
- runSeparatedRWS' :: ('[RWS' tag r w s, Reader' tag r, Writer' tag w, State' tag s] `EachVia` Separation) m a -> m a
- runSeparatedRWS :: ('[RWS r w s, Reader r, Writer w, State s] `EachVia` Separation) m a -> m a
- data Tagger tag new m a
- tagRWS' :: forall new r w s m a. ('[RWS' G r w s, Reader' G r, Writer' G w, State' G s] `EachVia` Tagger G new) m a -> m a
- retagRWS' :: forall tag new r w s m a. ('[RWS' tag r w s, Reader' tag r, Writer' tag w, State' tag s] `EachVia` Tagger tag new) m a -> m a
- untagRWS' :: forall tag r w s m a. ('[RWS' tag r w s, Reader' tag r, Writer' tag w, State' tag s] `EachVia` Tagger tag G) m a -> m a
Tagged RWS Effect
class (Reader' tag r m, Writer' tag w m, State' tag s m) => RWS' tag r w s m | tag m -> r w s Source #
An effect that adds the following features to a given computation:
- (R) an immutable environment (the "reader" part)
- (W) a write-only, accumulated output (the "writer" part)
- (S) a mutable state (the "state" part)
Since: 0.2.0.0
Instances
(Reader' tag r m, Writer' tag w m, State' tag s m) => RWS' (tag :: k) r w s (Separation m) Source # | |
Defined in Control.Effect.RWS | |
Control (RWS' tag r w s) t m => RWS' (tag :: k) r w s (EachVia ([] :: [Effect]) t m) Source # | |
Defined in Control.Effect.RWS | |
Find (RWS' tag r w s) effs t m => RWS' (tag :: k) r w s (EachVia (other ': effs) t m) Source # | |
Defined in Control.Effect.RWS | |
(Monad (t m), Reader' tag r (EachVia effs t m), Writer' tag w (EachVia effs t m), State' tag s (EachVia effs t m)) => RWS' (tag :: k) r w s (EachVia (RWS' tag r w s ': effs) t m) Source # | |
Defined in Control.Effect.RWS | |
(Monad m, Monoid w) => RWS' (tag :: k) r w s (RWST r w s m) Source # | |
Defined in Control.Effect.RWS | |
(Monad m, Monoid w) => RWS' (tag :: k) r w s (RWST r w s m) Source # | |
Defined in Control.Effect.RWS | |
(Monad m, Monoid w) => RWS' (tag :: k) r w s (RWST r w s m) Source # | |
Defined in Control.Effect.RWS.Strict | |
RWS' new r w s m => RWS' (tag :: k1) r w s (Tagger tag new m) Source # | |
Defined in Control.Effect.RWS |
Untagged RWS Effect
If you don't require disambiguation of multiple RWS effects (i.e., you only have one RWS effect in your monadic context), it is recommended to always use the untagged RWS effect.
Interpretations
data Separation m a Source #
The separation interpreter of the RWS effect. This type implements the RWS'
type class by splitting the effect into separate Reader'
, Writer'
and
State'
effects which can then be interpreted individually.
When interpreting the effect, you usually don't interact with this type directly, but instead use one of its corresponding interpretation functions.
Instances
:: ('[RWS' tag r w s, Reader' tag r, Writer' tag w, State' tag s] `EachVia` Separation) m a | The program whose RWS effect should be handled. |
-> m a | The program with its RWS effect handled. |
Runs the RWS effect via separation.
runSeparatedRWS :: ('[RWS r w s, Reader r, Writer w, State s] `EachVia` Separation) m a -> m a Source #
The untagged version of runSeparatedRWS'
.
Tagging and Untagging
data Tagger tag new m a Source #
The tagging interpreter of the RWS effect. This type implements the
RWS'
type class by tagging/retagging/untagging its reader, writer and state
components.
When interpreting the effect, you usually don't interact with this type directly, but instead use one of its corresponding interpretation functions.
Since: 0.2.0.0
Instances
RWS' new r w s m => RWS' (tag :: k1) r w s (Tagger tag new m) Source # | |
Defined in Control.Effect.RWS | |
RWS' new r w s m => Reader' (tag :: k1) r (Tagger tag new m) Source # | |
RWS' new r w s m => State' (tag :: k1) s (Tagger tag new m) Source # | |
RWS' new r w s m => Writer' (tag :: k1) w (Tagger tag new m) Source # | |
MonadBase b m => MonadBase b (Tagger tag new m) Source # | |
Defined in Control.Effect.RWS | |
MonadBaseControl b m => MonadBaseControl b (Tagger tag new m) Source # | |
MonadTrans (Tagger tag new :: (Type -> Type) -> Type -> Type) Source # | |
Defined in Control.Effect.RWS | |
MonadTransControl (Tagger tag new :: (Type -> Type) -> Type -> Type) Source # | |
Monad m => Monad (Tagger tag new m) Source # | |
Functor m => Functor (Tagger tag new m) Source # | |
Applicative m => Applicative (Tagger tag new m) Source # | |
Defined in Control.Effect.RWS pure :: a -> Tagger tag new m a # (<*>) :: Tagger tag new m (a -> b) -> Tagger tag new m a -> Tagger tag new m b # liftA2 :: (a -> b -> c) -> Tagger tag new m a -> Tagger tag new m b -> Tagger tag new m c # (*>) :: Tagger tag new m a -> Tagger tag new m b -> Tagger tag new m b # (<*) :: Tagger tag new m a -> Tagger tag new m b -> Tagger tag new m a # | |
MonadIO m => MonadIO (Tagger tag new m) Source # | |
Defined in Control.Effect.RWS | |
type StT (Tagger tag new :: (Type -> Type) -> Type -> Type) a Source # | |
type StM (Tagger tag new m) a Source # | |
Defined in Control.Effect.RWS |
Conversion functions between the tagged and untagged RWS effect, usually used in combination with type applications, like:
tagRWS'
@"newTag" programretagRWS'
@"oldTag" @"newTag" programuntagRWS'
@"erasedTag" program
tagRWS' :: forall new r w s m a. ('[RWS' G r w s, Reader' G r, Writer' G w, State' G s] `EachVia` Tagger G new) m a -> m a Source #