Build a computation that makes use of a callback, also known as a continuation.
Build a computation that makes use of a callback, also known as a continuation.
Example:
ContT.apply { callback => for { a <- doFirstThing() b <- doSecondThing(a) c <- callback(b) d <- doFourthThing(c) } yield d }
Similar to pure but evaluation of the argument is deferred.
Similar to pure but evaluation of the argument is deferred.
This is useful for building a computation which calls its continuation as the final step. Instead of writing:
ContT.apply { cb => val x = foo() val y = bar(x) val z = baz(y) cb(z) }
you can write:
ContT.defer { val x = foo() val y = bar(x) baz(y) }
Similar to apply but evaluation of the argument is deferred.
Lift a pure value into ContT