turbolift.Effect
See theEffect companion object
Base trait for any user-defined effect.
Instances of Effect
are used for:
- Establishing unique identity of the effect.
- Invoking operations of the effect.
Example:
import turbolift.{!!, Signature, Effect}}
trait GoogleSignature extends Signature:
def countPicturesOf(topic: String): Int !@! ThisEffect
// Boilerplate:
trait Google extends Effect[GoogleSignature] with GoogleSignature:
final override def countPicturesOf(topic: String): Int !! this.type = 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.