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
Known subtypes
class FlatMap[A, B, U]
class Impure[A]
class Intrinsic[A, U]
class LocalGetsEff[A, U, S]
class LocalModify[S]
class LocalUpdate[A, B, S]
class Perform[A, U, Z]
class PureMap[A, B, U]
class Sync[A, B]
Show all

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]

Parallel version of ++!.

Parallel version of ++!.

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[_], G[_], L, N](f: A => Handler[F, G, L, N]): Handler[F, G, L, U & N]
Extension method from Computation

Alias of flatMapHandler

Alias of flatMapHandler

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

final def cast[A2, U2]: Computation[A2, U2]
def castEv[U2](using ev: U2 =:= U): Computation[A, U2]
Extension method from Computation
final def delay[U2 <: U & IO](millis: Long): Computation[A, U2]
final def delay[U2 <: U & IO](duration: FiniteDuration): Computation[A, U2]
def downCast[U2 >: U]: Computation[A, U2]
Extension method from Computation
final def executeOn[U2 <: U & IO](exec: Executor): Computation[A, U2]
def finalized: Computation[A, U]
Extension method from Computation
final inline def flatMap[B, U2 <: U](inline 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
def flatMapHandler[F[_], G[_], L, N](f: A => Handler[F, G, L, N]): Handler[F, G, L, U & N]
Extension method from Computation

Creates a handler effectfully.

Creates a handler effectfully.

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

Attributes

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 computation.flatMapHandler(handler => handler).

Attributes

final def fork: Computation[Fiber[A, U], U & IO & Warp]

Run this computation in a new fiber.

Run this computation in a new fiber.

Attributes

final def forkAt(warp: Warp): Computation[Fiber[A, U], U & IO]

Like fork, but the fiber is created as a child of specific warp, rather than the current warp.

Like fork, but the fiber is created as a child of specific warp, rather than the current warp.

Attributes

final def guarantee[U2 <: U & IO](release: Computation[Unit, U2]): Computation[A, U2]
def handleWith[V]: HandleWithSyntax[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 inline def map[B](inline f: A => B): Computation[B, U]
def map2[C](f: (A, B) => C): Computation[C, U]
Extension method from Computation
final def named[A2 >: A, U2 <: U](name: String): NamedSyntax[A2, U2]

Syntax for giving names to fibers.

Syntax for giving names to fibers.

Attributes

final def onCancel[U2 <: U & IO](comp: Computation[Unit, U2]): Computation[A, U2]
final def onFailure[U2 <: U & IO](f: Throwable => Computation[Unit, U2]): Computation[A, U2]
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 runAsync(using mode: Mode)(callback: Outcome[A] => Unit): Unit
Extension method from Computation
def runIO(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 runIOMT: Outcome[A]
Extension method from Computation
def runIOST: Outcome[A]
Extension method from Computation
def runMT: A
Extension method from Computation
def runST: A
Extension method from Computation
final def tapEff[B, U2 <: U](f: A => Computation[B, U2]): Computation[A, U2]
def unsafeRun(using mode: Mode): Outcome[A]
Extension method from Computation
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 warp: Computation[A, U]
Extension method from Computation
def warp(exitMode: ExitMode, name: String): Computation[A, U]
Extension method from Computation
def warpAwait: Computation[A, U]
Extension method from Computation
def warpAwait(name: String): Computation[A, U]
Extension method from Computation
def warpCancel: Computation[A, U]
Extension method from Computation
def warpCancel(name: String): Computation[A, U]
Extension method from Computation
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

Deprecated methods

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

Attributes

Deprecated
true