Handler

turbolift.Handler
See theHandler companion object
sealed trait Handler[From[_], To[_], Elim, Intro]

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
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Type members

Classlikes

final class HandleApply[V]

Attributes

Supertypes
class Object
trait Matchable
class Any
class PartiallyProvideWithApply[Remains >: Intro]

Attributes

Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

final def %%![Remains >: Intro]: PartiallyProvideWithApply[Remains]

Attributes

final def %%%![From2[_], To2[_], Intro2](that: Handler[From2, To2, Intro, Intro2])(using ev: CanPipe[To, From2]): Handler[[X] =>> From[From2[X]], [X] =>> To2[To[X]], Elim, Intro2]

Alias for provideWith.

Alias for provideWith.

Attributes

final def &&&![From2[_], To2[_], Elim2, Intro2](that: Handler[From2, To2, Elim2, Intro2])(using ev: CanPipe[To, From2]): Handler[[X] =>> From[From2[X]], [X] =>> To2[To[X]], Elim & Elim2, Intro & Intro2]

Alias for composeWith.

Alias for composeWith.

Attributes

def ***![S2, S3, L2, N2](that: FromId[Tuple2, L2, N2])(using ET: ExtendTuple[S, S2, S3]): Handler[F, Tuple2, L & L2, N & N2]
Extension method from Handler

Composes 2 independent handlers, also flattening their nested Tuple2 results.

Composes 2 independent handlers, also flattening their nested Tuple2 results.

((_, S1), S2) ~> (_, (S1, S2))
((_, S1, S2), S3) ~> (_, (S1, S2, S3))
((_, S1, S2, S3), S4) ~> (_, (S1, S2, S3, S4))
...

Attributes

final def composeWith[From2[_], To2[_], Elim2, Intro2](that: Handler[From2, To2, Elim2, Intro2])(using ev: CanPipe[To, From2]): Handler[[X] =>> From[From2[X]], [X] =>> To2[To[X]], Elim & Elim2, Intro & Intro2]

Composes 2 independent handlers.

Composes 2 independent handlers.

Independence of handlers means, that effects eliminated by one of the handlers, do not overlap with effects introduced by the other.

Independence of 2 handlers guarantees, that it's also valid to compose them in the opposite order. However, nesting order of their To[_]s would also be reversed.

Attributes

final def contraMapEffK[From2[_], V](f: [X] => (x$1: From2[X]) => Computation[From[X], V]): Handler[From2, To, Elim, Intro & V]

Like contraMapK, but the pre-processing of From[_] can also introduce effects.

Like contraMapK, but the pre-processing of From[_] can also introduce effects.

Those effects are then absorbed by the new handler into the effects it introduces.

Attributes

final def contraMapK[From2[_]](f: [X] => (x$1: From2[X]) => From[X]): Handler[From2, To, Elim, Intro]

Transforms this handler, by applying a pre-processing function to its input`.

Transforms this handler, by applying a pre-processing function to its input`.

Attributes

final def contraTapEffK[V](f: [X] => (x$1: From[X]) => Computation[Unit, V]): Handler[From, To, Elim, Intro & V]

Like contraMapEffK, but the pre-processing is executed for its effects only.

Like contraMapEffK, but the pre-processing is executed for its effects only.

This handler's From[_] remains unchanged.

Attributes

def dropState: ToId[F, L, N]
Extension method from Handler

Transforms this handler, by dropping the second element of its Tuple2 result.

Transforms this handler, by dropping the second element of its Tuple2 result.

Attributes

def eval: ToId[F, L, N]
Extension method from Handler

Alias for dropState.

Alias for dropState.

Attributes

def exec: ToConst[F, S, L, N]
Extension method from Handler

Alias for justState.

Alias for justState.

Attributes

def flatMapLeft[E2, U](f: E => Computation[E2, U]): Handler[F, [_] =>> Either[E2, _$53], L, N & U]
Extension method from Handler

Like mapLeft, but the mapping function is effectful.

Like mapLeft, but the mapping function is effectful.

Attributes

def flatMapState[S2, U](f: S => Computation[S2, U]): Handler[F, Tuple2, L, N & U]
Extension method from Handler

Like mapState, but the mapping function is effectful.

Like mapState, but the mapping function is effectful.

Attributes

def flatTapLeft[U](f: E => Computation[Unit, U]): Handler[F, [_] =>> Either[E, _$55], L, N & U]
Extension method from Handler

Like flatMapLeft, but the mapping is executed for its effects only.

Like flatMapLeft, but the mapping is executed for its effects only.

Attributes

def flatTapState[S2, U](f: S => Computation[Unit, U]): Handler[F, Tuple2, L, N & U]
Extension method from Handler

Like flatMapState, but the mapping is executed for its effects only.

Like flatMapState, but the mapping is executed for its effects only.

Attributes

def getOrDie(message: => String): ToId[F, L, N]
Extension method from Handler

Transforms this handler, by deconstructing its Option result.

Transforms this handler, by deconstructing its Option result.

Attributes

def getOrDie(message: E => String): ToId[F, L, N]
Extension method from Handler

Transforms this handler, by deconstructing its Either result.

Transforms this handler, by deconstructing its Either result.

Attributes

def getOrElse(default: => Nothing): ToId[F, L, N]
Extension method from Handler

Transforms this handler, by deconstructing its Option result.

Transforms this handler, by deconstructing its Option result.

Attributes

def getOrElse(default: E => Nothing): ToId[F, L, N]
Extension method from Handler

Transforms this handler, by deconstructing its Either result.

Transforms this handler, by deconstructing its Either result.

Attributes

final def handle[V]: HandleApply[V]

Applies this handler to given computation.

Applies this handler to given computation.

Equivalent of Computation's handleWith(this)

Attributes

def justState: ToConst[F, S, L, N]
Extension method from Handler

Transforms this handler, by dropping the first element of its Tuple2 result.

Transforms this handler, by dropping the first element of its Tuple2 result.

Attributes

final def mapEffK[To2[_], V](f: [X] => (x$1: To[X]) => Computation[To2[X], V]): Handler[From, To2, Elim, Intro & V]

Like mapK, but the post-processing of To[_] can also introduce effects.

Like mapK, but the post-processing of To[_] can also introduce effects.

Those effects are then absorbed by the new handler into the effects it introduces.

Attributes

final def mapK[To2[_]](f: [X] => (x$1: To[X]) => To2[X]): Handler[From, To2, Elim, Intro]

Transforms this handler, by applying a post-processing function to its result`.

Transforms this handler, by applying a post-processing function to its result`.

a.k.a Natural Transformation.

Attributes

def mapLeft[E2](f: E => E2): Handler[F, [_] =>> Either[E2, _$52], L, N]
Extension method from Handler

Transforms this handler, by mapping the Left branch of its Either result.

Transforms this handler, by mapping the Left branch of its Either result.

Attributes

def mapState[S2](f: S => S2): Handler[F, Tuple2, L, N]
Extension method from Handler

Transforms this handler, by mapping the second element of its Tuple2 result.

Transforms this handler, by mapping the second element of its Tuple2 result.

Attributes

final def partiallyProvideWith[Remains >: Intro]: PartiallyProvideWithApply[Remains]

Composes 2 partially dependent handlers.

Composes 2 partially dependent handlers.

Assumes that some of effects introduced by this handler, are eliminated by that handler.

Attributes

final def project[C](using CanPipe[[_] =>> C, From]): Handler[[_] =>> C, [_] =>> To[C], Elim, Intro]

Specializes this handler, making it applicable only to computations returning C type.

Specializes this handler, making it applicable only to computations returning C type.

Removes universal quantification of the handler over its input type.

Attributes

final def provideWith[From2[_], To2[_], Intro2](that: Handler[From2, To2, Intro, Intro2])(using ev: CanPipe[To, From2]): Handler[[X] =>> From[From2[X]], [X] =>> To2[To[X]], Elim, Intro2]

Composes 2 fully dependent handlers.

Composes 2 fully dependent handlers.

Assumes that all effects introduced by this handler, are eliminated by that handler.

Attributes

final def tapEffK[V](f: [X] => (x$1: To[X]) => Computation[Unit, V]): Handler[From, To, Elim, Intro & V]

Like mapEffK, but the post-processing is executed for its effects only.

Like mapEffK, but the post-processing is executed for its effects only.

This handler's To[_] remains unchanged.

Attributes

def toEither[E](e: => E): Handler[F, [_] =>> Either[E, _$48], L, N]
Extension method from Handler

Transforms this handler, by mapping its Option result to Either.

Transforms this handler, by mapping its Option result to Either.

Attributes

def toOption: Handler[F, Option, L, N]
Extension method from Handler

Transforms this handler, by mapping its Either result to Option.

Transforms this handler, by mapping its Either result to Option.

Attributes

def toTry(e: => Throwable): Handler[F, Try, L, N]
Extension method from Handler

Transforms this handler, by mapping its Option result to Try.

Transforms this handler, by mapping its Option result to Try.

Attributes

def toTry(implicit ev: E <:< Throwable): Handler[F, Try, L, N]
Extension method from Handler

Transforms this handler, by mapping its Either result to Try.

Transforms this handler, by mapping its Either result to Try.

Attributes

def toVector: Handler[F, Vector, L, N]
Extension method from Handler

Transforms this handler, by mapping its Option result to Vector.

Transforms this handler, by mapping its Option result to Vector.

Attributes

def unsafeGet: ToId[F, L, N]
Extension method from Handler

Transforms this handler, by deconstructing its Option result.

Transforms this handler, by deconstructing its Option result.

Attributes

final def void: Handler[From, [X] =>> Unit, Elim, Intro]

Transforms this handler, by discarding its result.

Transforms this handler, by discarding its result.

Attributes

def |||![L2, N2](that: FromId[Option, L2, N2]): Handler[F, Option, L & L2, N & N2]
Extension method from Handler

Composes 2 independent handlers, also flattening their nested Option results.

Composes 2 independent handlers, also flattening their nested Option results.

Option[Option[_]] ~> Option[_]

Attributes

def |||![E2, L2, N2](that: FromId[[_] =>> Either[E2, _$56], L2, N2]): Handler[F, [_] =>> Either[E | E2, _$57], L & L2, N & N2]
Extension method from Handler

Composes 2 independent handlers, also flattening their nested Either results.

Composes 2 independent handlers, also flattening their nested Either results.

Either[E2, Either[E1, _]] ~> Either[E1 | E2, _]

Attributes