turbolift
Members list
Packages
Type members
Classlikes
Monad parametrized by a set of requested effect. Use the !!
infix type alias instead.
Monad parametrized by a set of requested effect. Use the !!
infix type alias instead.
Type-level set of effects is modelled with intersection types. Type Any
means empty set.
type MyComputationType1 = String !! (MyState & MyError)
type MyComputationType2 = String !! Any
Type parameters
- A
-
Result of the computation
- U
-
Type-level set of effects requested by this computation.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Use the !!
alias to access methods of this companion object.
Use the !!
alias to access methods of this companion object.
Example:
import turbolift.!!
val myComputation: Int !! Any = !!.pure(42)
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Computation.type
Base trait for any user-defined effect.
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
Orphaned extensions.
Orphaned extensions.
Extensions of standard library types, like Iterable
, Iterator
, etc.
Usage: just import them all.
import turbolift.Extensions._
Attributes
- Supertypes
-
trait TraverseExtensionstrait FoldExtensionstrait MiscExtensionsclass Objecttrait Matchableclass AnyShow all
- Self type
-
Extensions.type
Used to delimit scope of effect(s).
Used to delimit scope of effect(s).
Handler transforms a Computation, by discharging some or all of its requested effects, and (optionally) introducing handlers own dependencies to it (set of effects used to create the handler).
val myComputation2 = myComputation1.handleWith(myHandler)
Handlers can be obtained by:
- implementing an Interpreter for an Effect, and then calling
toHandler
method on it. - transforming a preexisting handler, e.g.
val myHandler2 = myHandler1.map(...)
- composing 2 preexisting handlers, e.g.
val myHandler3 = myHandler1 &&&! myHandler2
Compositon of 2 handlers is always sequential: the operands are applied in left to right order.
The From[_]
type parameter can only have 2 forms:
- type-level identity function:
[X] =>> X
- type-level constant function:
[_] =>> C
The To[_]
type parameter has no restrictions, but often happens to be identity.
Type parameters
- Elim
-
Type-level set of effects, that this handler eliminates from the computation.
- From
-
Type constructor, indicating what computation's result types can be accepted by this handler as input.
- Intro
-
Type-level set of effects, that this handler introduces into the computation. This is often an empty set, expressed as
Any
. - To
-
Type constructor (e.g.
Option[_]
), in which the computation's result is wrapped, after application of this handler.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Base trait for any user-defined effect signature. Used to define custom Algebra/Service/DSL.
Base trait for any user-defined effect signature. Used to define custom Algebra/Service/DSL.
Example:
import turbolift.Signature
trait GoogleSignature extends Signature:
def countPicturesOf(topic: String): Int !@! ThisEffect
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait ChoiceSignaturetrait Choiceobject Each.typetrait ConsoleSignaturetrait ConsoleEffectobject Console.typetrait Error[E]trait IOobject IO.typetrait RandomSignaturetrait RandomEffectobject Random.typetrait ReaderSignature[R]trait Reader[R]trait StateSignature[S]trait State[S]trait Writer[W]trait CanPerform[Z]trait Effect[Z]trait Interpreterclass Proxy[Fx]class Proxy[Fx]class Free[G]class Free[D]class ToId[Fx]class Freeclass Free[G]class Free[D]class ToId[Fx]class FreeShow all
Types
Alias for Computation type. Meant to be used in infix form.
Value members
Concrete methods
Alias for Computation companion object.