The continuation monad, if written in Scala, is basically
opaque type Cont[R, +A] = (A => R) => R
This type signature, (A => R) => R
, is suspiciously similar to foreach
in Traversable
/Future
etc:
def foreach[R](f: A => R) => Unit
If written in a lambda form, and assuming R =:= Unit
, this is (A => Unit) => Unit
, which is a continuation of return type Unit
.
I do not fully understand the connection here: can we safely consider Traversable
/Observable
s as continuations which admits a callback function A => Unit
?