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 Choice
object Each.type
object Console.type
trait ErrorEffect[E, E1]
trait Error[E]
trait ErrorG[M, K, V]
trait ErrorGK[M, K, F, V]
trait ErrorK[F, E]
trait RandomEffect
object Random.type
trait Reader[R]
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 = Effect.this.type

Abstract type that must be used in definitions of effect's operations.

Abstract type that must be used in definitions of effect's operations.

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

Attributes

Inherited types

final override type !@![+A, U] = Computation[A, U]

Abstract type that must be used in definitions of effect's operations.

Abstract type that must be used in definitions of effect's operations.

Becomes an alias of Computation (i.e. same as !!), once the signature is inherited from Effect.

Attributes

Inherited from:
CanPerform

Value members

Concrete methods

final def &![Fx2 <: Signature](fx2: Fx2): Combine2[Effect, Fx2]

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 def perform[A, U <: ThisEffect](f: (z: Z & Signature { type ThisEffect = U; }) => 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 val ThisHandler: ThisHandler.type
Exported from EffectImpl
final type ThisHandler = [F[_], G[_], N] =>> ThisHandler[F, G, N]
Exported from EffectImpl