trait Interpret extends AnyRef
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 Interpreter
trait you need to define:
- what to do with pure values
- what to do with an effect
- what to do with a list of effects (the "applicative" case)
- what to do with a "last" effect, in case of having side-effects to finalize resources (see the SafeEffect)
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 recurse
method and the Recurser
trait define:
- onPure(a: A): B: how to map a pure value A to the result B
- onEffect[X](mx: M[X]): X Either Eff[R, B]: either extract a value from the effect or return another effect
- onApplicative[X](tx: T[M[X]]): T[X] Either M[T[X]]: either extract individual values from each effect or "sequence" the effect
Even simpler, the Translate
trait does a translation from an effect M[X]
to other effects in the stack.
There are also a few intercept
methods to use an effect but still leave it in the stack
- Alphabetic
- By Inheritance
- Interpret
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def augment[R, T[_], O[_], A](eff: Eff[R, A])(w: Augment[T, O])(implicit memberT: MemberInOut[T, R], memberO: MemberIn[O, R]): Eff[R, A]
Interpret the effect T with a side-effect O (see the write method below)
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def intercept[R, T[_], A, B](e: Eff[R, A])(interpreter: Interpreter[T, R, A, B])(implicit m: /=[T, R]): Eff[R, B]
- def interceptNat[R, T[_], A](effect: Eff[R, A])(nat: ~>[T, T])(implicit m: /=[T, R]): Eff[R, A]
Intercept the values for one effect and transform them into other values for the same effect
- def interceptNatM[R, M[_], F[_], A](effect: Eff[R, A], nat: ~>[M, [A]M[F[A]]])(implicit m: MemberInOut[M, R], FT: Traverse[F], FM: Monad[F]): Eff[R, F[A]]
Intercept the values for one effect, emitting new values for the same effect inside a monad which is interleaved in
- def interpretUnsafe[R, U, T[_], A](effect: Eff[R, A])(sideEffect: SideEffect[T])(implicit m: Aux[T, R, U]): Eff[U, A]
interpret an effect by running side-effects
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def recurse[R, U, T[_], A, B](e: Eff[R, A])(recurser: Recurser[T, U, A, B])(implicit m: Aux[T, R, U]): Eff[U, B]
Interpret an effect with a Recurser
- def runInterpreter[R, U, T[_], A, B](e: Eff[R, A])(interpreter: Interpreter[T, U, A, B])(implicit m: Aux[T, R, U]): Eff[U, B]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def trace[R, T[_], A](eff: Eff[R, A])(implicit memberT: MemberInOut[T, R], memberW: MemberInOut[[β$4$]WriterT[[A]A, T[_], β$4$], R]): Eff[R, A]
For a single effect T log every value of that effect
- def transform[SR, BR, U1, U2, TS[_], TB[_], A](effect: Eff[SR, A], nat: ~>[TS, TB])(implicit sr: Aux[TS, SR, U1], br: Aux[TB, BR, U2], into: IntoPoly[U1, U2]): Eff[BR, A]
transform an effect into another one using a natural transformation, leaving the rest of the stack untouched
- def translate[R, U, T[_], A](effect: Eff[R, A])(tr: Translate[T, U])(implicit m: Aux[T, R, U]): Eff[U, A]
Translate one effect of the stack into some of the other effects in the stack
- def translateInto[R, T[_], U, A](effect: Eff[R, A])(tr: Translate[T, U])(implicit t: /=[T, R], into: IntoPoly[R, U]): Eff[U, A]
Translate one effect of the stack into other effects in a larger stack
- def translateNat[R, U, T[_], A](effects: Eff[R, A])(nat: ~>[T, [β$0$]Eff[U, β$0$]])(implicit m: Aux[T, R, U]): Eff[U, A]
Translate one effect of the stack into some of the other effects in the stack Using a natural transformation
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def write[R, T[_], O, A](eff: Eff[R, A])(w: Write[T, O])(implicit memberT: MemberInOut[T, R], memberW: MemberIn[[β$1$]WriterT[[A]A, O, β$1$], R]): Eff[R, A]
For each effect T add some "log statements" O using the Writer effect