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