Generalisation of Recurse and StateRecurse
Helper trait for computations which might produce several M[X] in a stack of effects.
Helper trait for computations which might produce several M[X] in a stack of effects.
Either we can produce an X to pass to a continuation or we're done
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[M |: 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
interpret the effect M in the M |: 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
transform an effect into another one using a natural transformation
Support methods to create an interpreter (or "effect handlers") for a given Eff[M |: R, A]. The aim being to "consume" just that effect and produce a value of type B with possibly other effects: Eff[R, B]
Those methods guarantee a stack-safe behaviour when running on a large list of effects (in a list.traverseU(f) for example).
There are 3 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)