Computation

sealed trait Computation[+A, -U]

Monad of extensible effects. Use the !! infix type alias instead.

For example:

type MyComputationType1 = String !! (MyState & MyError)

type MyComputationType2 = String !! Any

MyComputationType1 is a type of computations that return String and reqest 2 effects: MyState and MyError.

MyComputationType2 is a type of computations that return String and reqest no effects (type Any means empty set).


All requested effects must be handled (discharged from the computation), by using Handlers, before the result can be obtained as a plain (non monadic) value.

To handle some or all requested effects, use handleWith:

val myComputation2 = myComputation.handleWith(myHandler)

As soon as all effects are handled, the result can be obtained with run:

val result = someComputation
  .handleWith(someHandler1)
  .handleWith(someHandler2)
  .handleWith(someHandler3)
  .run
Type parameters:
A

Result type of the computation

U

Type-level set of effects, expressed as an intersection type, that are requested by this computation. Type Any means empty set.

Companion:
object
class Object
trait Matchable
class Any

Value members

Concrete methods

final def &![B, U2 <: U](that: Computation[B, U2]): Computation[B, U2]
final def &&![B, U2 <: U](that: => Computation[B, U2]): Computation[B, U2]
final def &&<![B, U2 <: U](that: => Computation[B, U2]): Computation[A, U2]
final def &<![B, U2 <: U](that: Computation[B, U2]): Computation[A, U2]
final def *![B, U2 <: U](that: Computation[B, U2]): Computation[(A, B), U2]
final def **![B, U2 <: U](that: => Computation[B, U2]): Computation[(A, B), U2]
final def >>=[B, U2 <: U](f: A => Computation[B, U2]): Computation[B, U2]
final def as[B](value: B): Computation[B, U]
final def flatMap[B, U2 <: U](f: A => Computation[B, U2]): Computation[B, U2]
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]
final def map[B](f: A => B): Computation[B, U]
final def upCast[U2 <: U]: Computation[A, U2]
final def void: Computation[Unit, U]
final def withFilter[U2 <: U & ChoiceSig](f: A => Boolean): Computation[A, U2]
final def zip[B, U2 <: U](that: Computation[B, U2]): Computation[(A, B), U2]
final def |![A2 >: A, U2 <: U & ChoiceSig](that: Computation[A2, U2]): Computation[A2, U2]
final def ||![A2 >: A, U2 <: U & ChoiceSig](that: => Computation[A2, U2]): Computation[A2, U2]

Inherited methods

def >>=!: Handler[F, L, U & N]
Extension method from Computation
Inherited from:
ComputationExtensions
def downCast: Computation[A, U2]
Extension method from Computation
Inherited from:
ComputationExtensions
def flatMap2: Computation[C, U2]
Extension method from Computation
Inherited from:
ComputationExtensions
def flattenHandler: Handler[F, L, N]
Extension method from Computation
Inherited from:
ComputationExtensions
Extension method from Computation
Inherited from:
ComputationExtensions
def if_!!: Computation[Unit, U2]
Extension method from Computation
Inherited from:
ComputationExtensions
def map2: Computation[C, U]
Extension method from Computation
Inherited from:
ComputationExtensions
def run: A
Extension method from Computation
Inherited from:
ComputationExtensions
def runWith: F[A]
Extension method from Computation
Inherited from:
ComputationExtensions
def until_!!: Computation[Unit, U2]
Extension method from Computation
Inherited from:
ComputationExtensions
def while_!!: Computation[Unit, U2]
Extension method from Computation
Inherited from:
ComputationExtensions