Helper trait for computations which might produce several M[X] in a stack of effects and which need to keep some state around
Helper trait for computations which might produce several M[X] in a stack of effects and which need to keep some state around
This is typically the case for Writer or State which need to keep some state S after each evaluation
Evaluating the effect M[X] might use the previous S value as shown in the apply method
Finally when the Eff[R, A] returns an A, this one can be combined with the last state value to produce a B
INTERPRET IN THE SAME STACK
simpler version of intercept where the pure value is just mapped to another type
intercept an effect and interpret it in the same stack.
intercept an effect and interpret it in the same stack. This method is stack-safe
Intercept the values for one effect and transform them into other values for the same effect
interpret the effect M in the R stack
simpler version of interpret where the pure value is just mapped to another type
generalization of interpret and interpretState
generalization of interpret and interpretState
This method contains a loop which is stack-safe
interpret the effect M in the M |: R stack, keeping track of some state
simpler version of interpret1 where the pure value is just mapped to another type
generalization of interpret
generalization of interpret
This method contains a loop which is stack-safe
interpret an effect by running side-effects
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
Support methods to create interpreters (or "effect handlers") for a given effect M and a value Eff[R, A] when M is a member of R.
Those methods guarantee a stack-safe behaviour when running on a large list of effects (in list.traverse(f) for example).
There are different types of supported interpreters:
This interpreter is used to handle effects which either return a value X from M[X] or stops with Eff[R, B] See an example of such an interpreter in Eval where we just evaluate a computation X for each Eval[X].
2. "interpretState" + StateRecurse
This interpreter is used to handle effects which either return a value X from M[X] or stops with Eff[R, B]
3. "interpretLoop" + Loop
The most generic kind of interpreter where we can even recurse in the case of Pure(a) (See ListEffect for such a use)
4. "intercept / interceptState / interceptLoop" methods are similar but they transform an effect to other effects in the same stack without removing it from the stack
5. "transform" to swap an effect T of a stack to another effect, using a Natural Transformation
6. "translate" to interpret one effect of a stack into other effects of the same stack using a Natural Transformation this is a specialized version of interpret + Recurse
7. "interpretUnsafe + SideEffect" when you have a side effecting function M[X] => X