State, lazy
Initial design: The state request carries with it the state mutator function We can use this request both for mutating and getting the state. But see below for a better design!
data State s v where
State :: (s->s) -> State s sIn this old design, we have assumed that the dominant operation is modify. Perhaps this is not wise. Often, the reader is most nominant.
See also below, for decomposing the State into Reader and Writer!
The conventional design of State
Instances3MonadBaseControl, Handle, StM
(MonadBase m m, LiftedBase m r) => MonadBaseControl m (Eff (State s ': r))Defined in extensible-effects-5.0.0.1 · Control.Eff.State.LazyHandle (State s) r a (s -> k)Defined in extensible-effects-5.0.0.1 · Control.Eff.State.LazyHandle 'State s' requests
type StM (Eff (State s ': r)) a = StM (Eff r) (a, s)Defined in extensible-effects-5.0.0.1 · Control.Eff.State.Lazy