Computation

turbolift.Computation
See theComputation companion class
object Computation

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

Members list

Type members

Classlikes

final class HandleWithSyntax[A, U, V](thiz: Computation[A, U])

Attributes

Supertypes
class Object
trait Matchable
class Any
final class NamedSyntax[A, U](val comp: Computation[A, U], val name: String)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object NamedSyntax

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

Executes empty operation from the innermost Choice effect in the current scope.

Executes empty operation from the innermost Choice effect in the current scope.

Attributes

def envAsk[A](f: Env => A): Computation[A, Any]
def envMod[A, U](f: Env => Env, body: Computation[A, U]): Computation[A, U]
def every[A, U](body: Computation[A, U & Each]): Computation[Vector[A], U]

Handles Each effect.

Handles Each effect.

Attributes

def everyVoid[A, U](body: Computation[Unit, U & Each]): Computation[Unit, U]

Handles Each effect, discarding the result.

Handles Each effect, discarding the result.

Attributes

def generate[A, B, U](init: A, cond: A => Boolean, inc: A => A)(body: A => Computation[B, U]): Computation[Vector[B], U]

Like iterate, but returns results of each iteration.

Like iterate, but returns results of each iteration.

Attributes

inline def impure[A](inline a: => A): Computation[A, Any]
def impureEff[A, U](comp: => Computation[A, U]): Computation[A, U]
def isParallel: Computation[Boolean, Any]
def isSequential: Computation[Boolean, Any]
def iterate[A, U](init: A, cond: A => Boolean, inc: A => A)(body: A => Computation[Unit, U]): Computation[A, U]

Like the standard for loop, but using computation instead of statement.

Like the standard for loop, but using computation instead of statement.

Returns last value of the iterated variable.

Attributes

def iterateUntil[A, U](init: A, cond: A => Boolean)(body: A => Computation[A, U]): Computation[A, U]

Like the standard for loop, but using computation instead of statement.

Like the standard for loop, but using computation instead of statement.

Returns last value of the iterated variable.

Attributes

def iterateWhile[A, U](init: A, cond: A => Boolean)(body: A => Computation[A, U]): Computation[A, U]

Like the standard for loop, but using computation instead of statement.

Like the standard for loop, but using computation instead of statement.

Returns last value of the iterated variable.

Attributes

def parallelly[A, U](body: Computation[A, U]): Computation[A, U]
def parallellyIf[A, U](cond: Boolean)(body: Computation[A, U]): Computation[A, U]
def pure[A](a: A): Computation[A, Any]
def repeat[U](n: Int)(body: => Computation[Unit, U]): Computation[Unit, U]

Repeats the computation, given number of times.

Repeats the computation, given number of times.

Attributes

def repeatUntil[U, U2 <: U](cond: Computation[Boolean, U])(body: => Computation[Unit, U2]): Computation[Unit, U2]

Repeats the computation, while the effectful condition is false.

Repeats the computation, while the effectful condition is false.

Attributes

def repeatWhile[U, U2 <: U](cond: Computation[Boolean, U])(body: => Computation[Unit, U2]): Computation[Unit, U2]

Repeats the computation, while the effectful condition is true.

Repeats the computation, while the effectful condition is true.

Attributes

def replicate[A, U](n: Int)(body: => Computation[A, U]): Computation[Vector[A], U]

Like repeat, but returns results of each iteration.

Like repeat, but returns results of each iteration.

Attributes

def sequentially[A, U](body: Computation[A, U]): Computation[A, U]
def sequentiallyIf[A, U](cond: Boolean)(body: Computation[A, U]): Computation[A, U]
def when[U](cond: Boolean)(body: => Computation[Unit, U]): Computation[Unit, U]

Like if-then statement, but the body is a computation

Like if-then statement, but the body is a computation

Attributes

Deprecated methods

def defer[A, U](comp: => Computation[A, U]): Computation[A, U]

Attributes

Deprecated
true

Concrete fields

val nil: Computation[List[Nothing], Any]

Same as !!.pure(Nil).

Same as !!.pure(Nil).

Attributes

val none: Computation[Option[Nothing], Any]

Same as !!.pure(None).

Same as !!.pure(None).

Attributes

val unit: Computation[Unit, Any]

Same as !!.pure(()).

Same as !!.pure(()).

Attributes

val vector: Computation[Vector[Nothing], Any]

Same as !!.pure(Vector()).

Same as !!.pure(Vector()).

Attributes

Extensions

Extensions

extension [A](thiz: Computation[A, Any])
def run(using mode: Mode): A

Runs the computation, provided that it requests no effects.

Runs the computation, provided that it requests no effects.

Attributes

def runMT: A
def runST: A
extension [A](thiz: Computation[A, IO])
def runAsync(using mode: Mode)(callback: (Outcome[A]) => Unit): Unit
def runIO(using mode: Mode): Outcome[A]

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]
def runIOST: Outcome[A]
def unsafeRun(using mode: Mode): Outcome[A]
def unsafeRunAsync(using mode: Mode)(callback: (Outcome[A]) => Unit): Unit
extension [A, U <: IO](thiz: Computation[A, U & Warp])
def warp: Computation[A, U]
def warp(exitMode: ExitMode, name: String): Computation[A, U]
def warpAwait: Computation[A, U]
def warpAwait(name: String): Computation[A, U]
def warpCancel: Computation[A, U]
def warpCancel(name: String): Computation[A, U]
extension [A, U <: IO](thiz: Computation[A, U & Finalizer])
def finalized: Computation[A, U]
extension [A, U](thiz: Computation[A, U])
def >>=![F[_], G[_], L, N](f: A => Handler[F, G, L, N]): Handler[F, G, L, U & N]

Alias of flatMapHandler

Alias of flatMapHandler

Attributes

def castEv[U2](using ev: U2 =:= U): Computation[A, U2]
def downCast[U2 >: U]: Computation[A, U2]
def flatMapHandler[F[_], G[_], L, N](f: A => Handler[F, G, L, N]): Handler[F, G, L, U & N]

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

def handleWith[V]: HandleWithSyntax[A, U, V]

Applies a handler to this computation.

Applies a handler to this computation.

Same as myHandler.handle(this).

Attributes

extension [F[_], G[_], L, N](thiz: Computation[Handler[F, G, L, N], N])
def flattenHandler: Handler[F, G, L, N]

Simplifies effectful creation of handlers.

Simplifies effectful creation of handlers.

Same as computation.flatMapHandler(handler => handler).

Attributes

extension [A, B, U](thiz: Computation[(A, B), U])
def flatMap2[C, U2 <: U](f: (A, B) => Computation[C, U2]): Computation[C, U2]
def map2[C](f: (A, B) => C): Computation[C, U]
extension [U](thiz: Computation[Boolean, U])
def ifEff[U2 <: U](thenBody: => Computation[Unit, U2])(elseBody: => Computation[Unit, U2]): Computation[Unit, U2]

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

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

Attributes

def untilEff[U2 <: U](body: => Computation[Unit, U2]): Computation[Unit, U2]

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

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

Attributes

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

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

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

Attributes