Effect

turbolift.Effect
See theEffect companion object
trait Effect[Z <: Signature] extends CanPerform[Z]

Base trait for any user-defined effect.

Instances of Effect are used:

  • To establish unique identity of the effect, both in type and value space.
  • By effect users: to invoke operations of the effect.
  • By creators of effect handlers: to access base classes needed for implementing interpreters for this effect.

Example:

import turbolift.{!!, Signature, Effect}}

// Signature:
trait GoogleSignature extends Signature:
 def countPicturesOf(topic: String): Int !! ThisEffect

// Boilerplate:
trait Google extends Effect[GoogleSignature] with GoogleSignature:
 final override def countPicturesOf(topic: String) = perform(_.countPicturesOf(topic))

// Instantiaton establishes the identity:
case object MyGoogle extends Google
type MyGoogle = MyGoogle.type

// Invoking operations:
val program: Int !! MyGoogle = MyGoogle.countPicturesOf("cat")

For details, see Defining your own effects and handlers.

Type parameters

Z

The Signature of this effect.

Attributes

Companion
object
Graph
Supertypes
trait CanPerform[Z]
trait Signature
class Object
trait Matchable
class Any
Known subtypes
trait ChoiceEffect
trait Choice
object Each
object Console
trait Cont[R]
trait CoroutineEffect[I, O, R]
trait ErrorEffect[E, E1]
trait Error[E]
trait ErrorG[M, K, V]
trait ErrorGK[M, K, F, V]
trait ErrorK[F, E]
trait FinalizerEffect[U]
object Finalizer
trait LazyMemoizerEffect[K, V]
trait LazyMemoizer[K, V]
trait MaybeEffect
trait Maybe
object Broken
object Maybe
trait MemoizerEffect[K, V]
trait Memoizer[K, V]
trait RandomEffect
object Random
trait ReaderEffect[R]
trait Reader[R]
trait StateEffect[S]
trait State[S]
trait WriterEffect[W, W1]
trait Writer[W]
trait WriterG[M, K, V]
trait WriterGK[M, K, F, V]
trait WriterK[F, W]
Show all
Self type
Z

Members list

Type members

Types

final override type ThisEffect = this.type

Self-reference to the effect being described by this Signature.

Self-reference to the effect being described by this Signature.

Becomes an alias of this.type, once the signature is inherited from Effect.

Attributes

Value members

Concrete methods

final def &![Fx2 <: Signature](fx2: Fx2): Combine2[this.type, fx2.type]

Combines with another Effect instance, for the purpose of sharing an Interpreter.

Combines with another Effect instance, for the purpose of sharing an Interpreter.

Attributes

Inherited methods

final inline def perform[A, U <: ThisEffect](inline f: (Z & Signature { type ThisEffect = U; }) => Computation[A, U]): Computation[A, U]

Lifts an invocation of this Signature's method into the Computation monad.

Lifts an invocation of this Signature's method into the Computation monad.

Attributes

Inherited from:
CanPerform

Concrete fields

Object containing type definitions, to be used for implementing Interpreters for this effect.

Object containing type definitions, to be used for implementing Interpreters for this effect.

Attributes

Exports

Defined exports

final type ThisHandler = [F[_], G[_], N] =>> impl.ThisHandler[F, G, N]
Exported from EffectImpl