turbolift.Effect
See theEffect companion object
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 // optional
// Alternative way to instantiate the effect, using macro to skip the boilerplate:
// (generates the `trait Google` above)
val MyGoogle = Effect.boilerplate[GoogleSignature]
type MyGoogle = MyGoogle.type // optional
// 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
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait ChoiceEffectobject Choiceobject Eachtrait ConsoleEffectobject Consoletrait Cont[R]trait ErrorEffect[E]trait MaybeEffectobject Brokenobject Maybetrait RandomEffectobject Randomtrait ReaderEffect[R]trait ResourceEffect[U]object ResourceIOtrait StateEffect[S]trait WriterEffect[W]
- Self type
-
Z
Members list
In this article