effet-0.4.0.0: An Effect System based on Type Classes
Copyright(c) Michael Szvetits 2020
LicenseBSD3 (see the file LICENSE)
Maintainertypedbyte@qualified.name
Stabilitystable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Control.Effect.RWS

Description

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

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

Instances details
(Reader' tag r m, Writer' tag w m, State' tag s m) => RWS' (tag :: k) r w s (Separation m) Source # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

Defined in Control.Effect.RWS

(Monad m, Monoid w) => RWS' (tag :: k) r w s (RWST r w s m) Source # 
Instance details

Defined in Control.Effect.RWS

(Monad m, Monoid w) => RWS' (tag :: k) r w s (RWST r w s m) Source # 
Instance details

Defined in Control.Effect.RWS

(Monad m, Monoid w) => RWS' (tag :: k) r w s (RWST r w s m) Source # 
Instance details

Defined in Control.Effect.RWS.Strict

RWS' new r w s m => RWS' (tag :: k2) r w s (Tagger tag new m) Source # 
Instance details

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.

type RWS r w s = RWS' G r w s Source #

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

Instances details
(Reader' tag r m, Writer' tag w m, State' tag s m) => RWS' (tag :: k) r w s (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Reader' tag r m => Reader' (tag :: k) r (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

ask' :: Separation m r Source #

local' :: (r -> r) -> Separation m a -> Separation m a Source #

reader' :: (r -> a) -> Separation m a Source #

State' tag s m => State' (tag :: k) s (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

get' :: Separation m s Source #

put' :: s -> Separation m () Source #

state' :: (s -> (s, a)) -> Separation m a Source #

Writer' tag w m => Writer' (tag :: k) w (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

tell' :: w -> Separation m () Source #

listen' :: Separation m a -> Separation m (w, a) Source #

censor' :: (w -> w) -> Separation m a -> Separation m a Source #

MonadBase b m => MonadBase b (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

liftBase :: b α -> Separation m α #

MonadBaseControl b m => MonadBaseControl b (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Associated Types

type StM (Separation m) a #

Methods

liftBaseWith :: (RunInBase (Separation m) b -> b a) -> Separation m a #

restoreM :: StM (Separation m) a -> Separation m a #

MonadTrans (Separation :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

lift :: Monad m => m a -> Separation m a #

MonadTransControl (Separation :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.RWS

Associated Types

type StT Separation a #

Methods

liftWith :: Monad m => (Run Separation -> m a) -> Separation m a #

restoreT :: Monad m => m (StT Separation a) -> Separation m a #

Monad m => Monad (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

(>>=) :: Separation m a -> (a -> Separation m b) -> Separation m b #

(>>) :: Separation m a -> Separation m b -> Separation m b #

return :: a -> Separation m a #

Functor m => Functor (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

fmap :: (a -> b) -> Separation m a -> Separation m b #

(<$) :: a -> Separation m b -> Separation m a #

Applicative m => Applicative (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

pure :: a -> Separation m a #

(<*>) :: Separation m (a -> b) -> Separation m a -> Separation m b #

liftA2 :: (a -> b -> c) -> Separation m a -> Separation m b -> Separation m c #

(*>) :: Separation m a -> Separation m b -> Separation m b #

(<*) :: Separation m a -> Separation m b -> Separation m a #

MonadIO m => MonadIO (Separation m) Source # 
Instance details

Defined in Control.Effect.RWS

Methods

liftIO :: IO a -> Separation m a #

type StT (Separation :: (Type -> Type) -> Type -> Type) a Source # 
Instance details

Defined in Control.Effect.RWS

type StT (Separation :: (Type -> Type) -> Type -> Type) a = StT (IdentityT :: (Type -> Type) -> Type -> Type) a
type StM (Separation m) a Source # 
Instance details

Defined in Control.Effect.RWS

type StM (Separation m) a = StM m a

runSeparatedRWS' Source #

Arguments

:: ('[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" program
    retagRWS' @"oldTag" @"newTag" program
    untagRWS' @"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 #

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 Source #

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 Source #