Computation

turbolift.Computation
See theComputation companion object
sealed abstract class Computation[+A, -U]

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

Members list

Value members

Concrete methods

final def &![B, U2 <: U](that: Computation[B, U2]): Computation[B, U2]

Composes 2 independent computations parallelly (if possible), discarding result of the first.

Composes 2 independent computations parallelly (if possible), discarding result of the first.

Parallelism may be impossible, due to at least one of handlers in current scope being inherently sequential (e.g. State.handlers.local or Error.handlers.first). In such case, &! behaves like &&!.

Attributes

final def &&![B, U2 <: U](that: => Computation[B, U2]): Computation[B, U2]

Composes 2 independent computations sequentially, discarding result of the first.

Composes 2 independent computations sequentially, discarding result of the first.

Attributes

final def &&<![B, U2 <: U](that: => Computation[B, U2]): Computation[A, U2]

Composes 2 independent computations sequentially, discarding result of the second.

Composes 2 independent computations sequentially, discarding result of the second.

Attributes

final def &<![B, U2 <: U](that: Computation[B, U2]): Computation[A, U2]

Composes 2 independent computations parallelly (if possible), discarding result of the second.

Composes 2 independent computations parallelly (if possible), discarding result of the second.

Parallelism may be impossible, due to at least one of handlers in current scope being inherently sequential (e.g. State.handlers.local or Error.handlers.first). In such case, &<! behaves like &&<!.

Attributes

final def *![B, U2 <: U](that: Computation[B, U2]): Computation[(A, B), U2]

Alias for zipPar.

Alias for zipPar.

Attributes

final def **![B, U2 <: U](that: => Computation[B, U2]): Computation[(A, B), U2]

Alias for zip.

Alias for zip.

Attributes

final def ++![A2 >: A, U2 <: U & ChoiceSignature](that: => Computation[A2, U2]): Computation[A2, U2]

Applies plus operation from the innermost Choice effect in the current scope.

Applies plus operation from the innermost Choice effect in the current scope.

Similar to <|> operator of Alternative.

Attributes

final def >>=[B, U2 <: U](f: A => Computation[B, U2]): Computation[B, U2]

Alias for flatMap.

Alias for flatMap.

Attributes

def >>=![F[_], L, N](f: A => Handler[[X] =>> X, F, L, N]): Handler[[X] =>> X, F, L, U & N]
Extension method from Computation

Simplifies effectful creation of handlers.

Simplifies effectful creation of handlers.

Passes computed value to handler constructor. Effect used to compute the value, are absorbed by the handler, into its own dependencies.

Attributes

def >>=![F[_], L, N](f: A => Handler[[_] =>> A, F, L, N]): Handler[[_] =>> A, F, L, U & N]
Extension method from Computation

Simplifies effectful creation of handlers.

Simplifies effectful creation of handlers.

Passes computed value to handler constructor. Effect used to compute the value, are absorbed by the handler, into its own dependencies.

Attributes

final def as[B](value: B): Computation[B, U]

Discards the result, and replaces it by given pure value.

Discards the result, and replaces it by given pure value.

Attributes

def downCast[U2 >: U]: Computation[A, U2]
Extension method from Computation
final def flatMap[B, U2 <: U](f: A => Computation[B, U2]): Computation[B, U2]
def flatMap2[C, U2 <: U](f: (A, B) => Computation[C, U2]): Computation[C, U2]
Extension method from Computation
final def flatTap[B, U2 <: U](f: A => Computation[B, U2]): Computation[A, U2]
final def flatten[B, U2 <: U](implicit ev: A <:< Computation[B, U2]): Computation[B, U2]
def flattenHandler: Handler[F, G, L, N]
Extension method from Computation

Simplifies effectful creation of handlers.

Simplifies effectful creation of handlers.

Same as Handler.flatHandle(this).

Attributes

def handleWith[V]: HandleWithApply[A, U, V]
Extension method from Computation

Applies a handler to this computation.

Applies a handler to this computation.

Same as myHandler.handle(this).

Attributes

def ifEff[U2 <: U](thenBody: => Computation[Unit, U2])(elseBody: => Computation[Unit, U2]): Computation[Unit, U2]
Extension method from Computation

Like if statement, but the condition and the body are computations.

Like if statement, but the condition and the body are computations.

Attributes

final def map[B](f: A => B): Computation[B, U]
def map2[C](f: (A, B) => C): Computation[C, U]
Extension method from Computation
def run(using mode: Mode): A
Extension method from Computation

Runs the computation, provided that it requests no effects.

Runs the computation, provided that it requests no effects.

Attributes

def runMT: A
Extension method from Computation
def runST: A
Extension method from Computation
final override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
def unsafeRun(using mode: Mode): Outcome[A]
Extension method from Computation

Runs the computation, provided that it requests IO effect only, or none at all.

Runs the computation, provided that it requests IO effect only, or none at all.

Attributes

def unsafeRunAsync(using mode: Mode)(callback: Outcome[A] => Unit): Unit
Extension method from Computation
Extension method from Computation
Extension method from Computation
def untilEff[U2 <: U](body: => Computation[Unit, U2]): Computation[Unit, U2]
Extension method from Computation

Like while statement, but the condition and the body are computations.

Like while statement, but the condition and the body are computations.

Attributes

final def upCast[U2 <: U]: Computation[A, U2]

Widens the set of requested effects.

Widens the set of requested effects.

Attributes

final def void: Computation[Unit, U]

Discards the result, and replaces it by Unit.

Discards the result, and replaces it by Unit.

Attributes

def whileEff[U2 <: U](body: => Computation[Unit, U2]): Computation[Unit, U2]
Extension method from Computation

Like while statement, but the condition and the body are computations.

Like while statement, but the condition and the body are computations.

Attributes

final def withFilter[U2 <: U & ChoiceSignature](f: A => Boolean): Computation[A, U2]

Applies filter, using empty operation from the innermost Choice effect in the current scope.

Applies filter, using empty operation from the innermost Choice effect in the current scope.

Attributes

final def zip[B, U2 <: U](that: => Computation[B, U2]): Computation[(A, B), U2]

Composes 2 independent computations sequentially

Composes 2 independent computations sequentially

Attributes

final def zipPar[B, U2 <: U](that: Computation[B, U2]): Computation[(A, B), U2]

Composes 2 independent computations parallelly (if possible).

Composes 2 independent computations parallelly (if possible).

Parallelism may be impossible, due to at least one of handlers in current scope being inherently sequential (e.g. State.handlers.local or Error.handlers.first). In such case, zipPar behaves like zip.

Attributes

final def zipWith[B, C, U2 <: U](that: => Computation[B, U2])(f: (A, B) => C): Computation[C, U2]

Like zip, but followed by untupled map.

Like zip, but followed by untupled map.

Attributes

final def zipWithPar[B, C, U2 <: U](that: Computation[B, U2])(f: (A, B) => C): Computation[C, U2]

Like zipPar, but followed by untupled map.

Like zipPar, but followed by untupled map.

Attributes

final def |![A2 >: A, U2 <: U & IO](that: Computation[A2, U2]): Computation[A2, U2]

Races 2 computations.

Races 2 computations.

Runs both computations parallelly, each in fresh fiber. Once one of them finishes, the other is cancelled.

Attributes

final def ||![A2 >: A, U2 <: U & IO](that: => Computation[A2, U2]): Computation[A2, U2]

Sequential "or-else" operator.

Sequential "or-else" operator.

Runs the first computations in fresh fiber. If it ends up cancelled, the second computation is run.

Attributes