Interpret the effect T with a side-effect O (see the write method below)
Intercept the values for one effect and transform them into other values for the same effect
Intercept the values for one effect, emitting new values for the same effect inside a monad which is interleaved in
interpret an effect by running side-effects
Interpret an effect with a Recurser
For a single effect T log every value of that effect
transform an effect into another one using a natural transformation, leaving the rest of the stack untouched
Translate one effect of the stack into some of the other effects in the stack
Translate one effect of the stack into other effects in a larger stack
Translate one effect of the stack into some of the other effects in the stack Using a natural transformation
For each effect T add some "log statements" O using the Writer effect
The Interpret trait provides method to interpret (or "handle") effects.
An interpreter generally handles a given effect M and a value Eff[R, A] where M is a member of R.
The most general way of interpreting an effect is to implement the Interpreter trait for that effect and use the runInterpreter method. With the
Interpretertrait you need to define:For each of those methods you get access to a continuation which you may or may not invoke to create the next effect in a sequence of effects. For example with the EitherEffect once you arrive on a Left value you don't trigger the continuation because there is no value to trigger it with.
There are also easier ways to define interpreters. The
recursemethod and theRecursertrait define:Even simpler, the
Translatetrait does a translation from an effectM[X]to other effects in the stack.There are also a few
interceptmethods to use an effect but still leave it in the stack