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
- 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 | |
Handle '[Reader' tag r, Writer' tag w, State' tag s] (RWS' tag r w s) others t m => RWS' (tag :: k) r w s (EachVia (RWS' tag r w s ': others) t m) Source # | |
Defined in Control.Effect.RWS | |
Find '[Reader' tag r, Writer' tag w, State' tag s] (RWS' tag r w s) other effs t m => RWS' (tag :: k) r w s (EachVia (other ': effs) t m) Source # | |
Defined in Control.Effect.RWS | |
Lift '[Reader' tag r, Writer' tag w, State' tag s] (RWS' tag r w s) t m => RWS' (tag :: k) r w s (EachVia ('[] :: [Effect]) 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 :: k2) 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
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 #