turbolift

package turbolift

Members list

Concise view

Type members

Classlikes

sealed abstract class Computation[+A, -U]

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

Attributes

A

Result of the computation

U

Type-level set of effects requested by this computation.

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class 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
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
trait Effect[Z <: Signature] extends CanPerform[Z] with CanInterpret

Base trait for any user-defined effect.

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.

Attributes

Z

The Signature of this effect.

Companion:
object
Graph
Supertypes
trait CanPerform[Z]
trait Signature
class Object
trait Matchable
class Any
Known subtypes
trait Choice
object Each.type
object Fail.type
object Console.type
trait ErrorEffect[E, E1]
trait Error[E]
trait ErrorK[F, E]
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]
Self type
object Effect

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Effect.type
object Extensions

Orphaned extensions.

Orphaned extensions.

import turbolift.Extensions._`

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait Handler[Result[_], Elim, Intro]

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, obtaining a Handler from it.
  • By transforming a preexisting handler, e.g. val myHandler2 = myHandler1.map(...)
  • By 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.

Attributes

Elim

Type-level set of effects, that this handler eliminates from the computation.

Intro

Type-level set of effects, that this handler introduces into the computation. This is often an empty set, expressed as Any.

Result

Type constructor (e.g. Option[_]), in which the computation's result is wrapped, after application of this handler. This is often an identity.

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
object Handler

Attributes

Companion:
trait
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Handler.type
trait Signature extends AnyRef

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

See Defining your own effects and handlers.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait ChoiceSig
trait Choice
object Each.type
object Fail.type
object Console.type
trait ErrorSig[E, E1]
trait ErrorEffect[E, E1]
trait Error[E]
trait ErrorK[F, E]
trait RandomSig
object Random.type
trait ReaderSig[R]
trait Reader[R]
trait StateSig[S]
trait State[S]
trait WriterSig[W, W1]
trait WriterEffect[W, W1]
trait Writer[W]
trait WriterG[M, K, V]
trait WriterGK[M, K, F, V]
trait WriterK[F, W]
trait CanPerform[Z]
trait Effect[Z]
class Flow
class Stateful[S, F]
class Stateful[S, F]
class Stateless[F]
class Stateless[F]
trait Proxy[Fx]
class Proxy[Fx]

Types

type !![+A, -U] = Computation[A, U]

Alias for Computation type. Meant to be used in infix form.

Alias for Computation type. Meant to be used in infix form.

Attributes

Value members

Concrete methods

def !!: Computation.type

Alias for Computation companion object.

Alias for Computation companion object.

Attributes