The captured computation so far. The type
(A => B, Exception => B) => C
is a function where:
A=>B
represents the computation defined against
the current state held in the ControlContext.Exception => B
represents a computation to
perform if an exception is thrown from the first parameter's computation.ControlContext
.The current state stored in this context. Allowed to be null if the context is non-trivial.
Maps and flattens this ControlContext
with another ControlContext
generated from the current state.
Maps and flattens this ControlContext
with another ControlContext
generated from the current state.
The new type of the contained state.
The new type of the state after the stored continuation has executed.
The result type of the nested ControlContext
. Because the nested ControlContext
is executed within
the outer ControlContext
, this type must >: B
so that the resulting nested computation can be fed through
the current continuation.
A transformation function from the current state to a nested ControlContext
.
The transformed ControlContext
.
The resulting comuptation is still the type C
.
Runs the computation against the state stored in this ControlContext
.
Runs the computation against the state stored in this ControlContext
.
the computation that modifies the current state of the context.
This method could throw exceptions from the computations.
Returns string formatted according to given format
string.
Returns string formatted according to given format
string.
Format strings are as for String.format
(@see java.lang.String.format).
The captured computation so far.
The captured computation so far. The type
(A => B, Exception => B) => C
is a function where:
A=>B
represents the computation defined against
the current state held in the ControlContext.Exception => B
represents a computation to
perform if an exception is thrown from the first parameter's computation.ControlContext
.The current state value.
true if this context only stores a state value and not any deferred computation.
Modifies the currently captured state in this ControlContext
.
Modifies the currently captured state in this ControlContext
.
The new type of state in this context.
A transformation function on the current state of the ControlContext
.
The new ControlContext
.
The current state stored in this context.
The current state stored in this context. Allowed to be null if the context is non-trivial.
This class represent a portion of computation that has a 'hole' in it. The class has the ability to compute state up until a certain point where the state has the
A
type. If this context is given a function of typeA => B
to move the state to theB
type, then the entire computation can be completed resulting in a value of typeC
.An Example:
This class is used to transform calls to
shift
in thecontinuations
package. Direct use and instantiation is possible, but usually reserved for advanced cases.A context may either be trivial or non-trivial. A trivial context just has a state of type
A
. When completing the computation, it's only necessary to use the function of typeA => B
directly against the trivial value. A non-trivial value stores a computation around the state transformation of typeA => B
and cannot be short-circuited.The type of the state currently held in the context.
The type of the transformed state needed to complete this computation.
The return type of the entire computation stored in this context.
fun
andx
are allowed to benull
.scala.util.continutations.shiftR