ScalaDSL
Supports manipulating Scala values via pure Scala functions. Also extends InvertDSL (and thus ClosedDSL), TimerDSL and CrashDSL, since these are expected to be possible on a target platform that already supports Scala functions.
Supports manipulating Scala values via pure Scala functions. Also extends InvertDSL (and thus ClosedDSL), TimerDSL and CrashDSL, since these are expected to be possible on a target platform that already supports Scala functions.
Type members
Types
Demand for a Scala value of type A
.
Demand for a Scala value of type A
.
Somewhat analogous to scala.concurrent.Promise
Inherited types
Libretto arrow, also called a ''component'' or a ''linear function''.
Libretto arrow, also called a ''component'' or a ''linear function''.
┏━━━━━━━━━━┓
┞───┐ ┞───┐
╎ A │ ╎ B │
┟───┘ ┟───┘
┗━━━━━━━━━━┛
In A -⚬ B
, we say that the ''in-port'' is of type A
and the ''out-port'' is of type B
.
Note that the distinction between the in-port and the out-port is only formal. Information or resources
may flow in and out through both the in-port and the out-port.
"Linear" means that each input is ''consumed'' exactly once, in particular, it cannot be ignored or used twice.
- Inherited from
- CoreDSL
Signal that travels in the direction of -⚬, i.e. the positive direction. It may signal completion of a (potentially effectful) computation. It cannot be ignored. (If this signal was the only handle to an (effectful) computation, ignoring it would mean losing track of that computation, which is considered to be a resource leak.)
Signal that travels in the direction of -⚬, i.e. the positive direction. It may signal completion of a (potentially effectful) computation. It cannot be ignored. (If this signal was the only handle to an (effectful) computation, ignoring it would mean losing track of that computation, which is considered to be a resource leak.)
- Inherited from
- CoreDSL
Signal that travels in the direction opposite to -⚬, i.e. the negative direction. It may signal completion of a (potentially effectful) computation. It cannot be ignored. (If this signal was the only handle to an (effectful) computation, ignoring it would mean losing track of that computation, which is considered to be a resource leak.)
Signal that travels in the direction opposite to -⚬, i.e. the negative direction. It may signal completion of a (potentially effectful) computation. It cannot be ignored. (If this signal was the only handle to an (effectful) computation, ignoring it would mean losing track of that computation, which is considered to be a resource leak.)
- Inherited from
- CoreDSL
Signal that travels in the direction opposite to -⚬, i.e. the negative direction. Unlike Need, it cannot be the only handle to an effectful computation. As such, it can be ignored, e.g. as the losing contestant in selectPair.
Signal that travels in the direction opposite to -⚬, i.e. the negative direction. Unlike Need, it cannot be the only handle to an effectful computation. As such, it can be ignored, e.g. as the losing contestant in selectPair.
- Inherited from
- CoreDSL
Choice between A
and B
.
The consumer chooses whether to get A
or B
(but can get only one of them).
The producer has to be ready to provide either of them.
Choice between A
and B
.
The consumer chooses whether to get A
or B
(but can get only one of them).
The producer has to be ready to provide either of them.
- Inherited from
- CoreDSL
Concurrent pair. Also called a ''tensor product'' or simply ''times''.
Concurrent pair. Also called a ''tensor product'' or simply ''times''.
- Inherited from
- CoreDSL
Either A
or B
. Analogous to scala.Either.
Whether it is going to be A
or B
is decided by the producer.
The consumer has to be ready to handle either of the two cases.
Either A
or B
. Analogous to scala.Either.
Whether it is going to be A
or B
is decided by the producer.
The consumer has to be ready to handle either of the two cases.
- Inherited from
- CoreDSL
Value members
Abstract methods
Acquires a resource of type R.
Acquires a resource of type R.
- Type Params
- A
parameters of the
acquire
function- B
additional data produced by acquiring the resource
- R
type of the resource
- Value Params
- release
called to release the resource in case of a crash.
None
means no cleanup is needed
Executes a potentially blocking operation. The implementation must ensure that the blocking operation does not impede any of the concurrently happening non-blocking computations.
Executes a potentially blocking operation. The implementation must ensure that the blocking operation does not impede any of the concurrently happening non-blocking computations.
Lifts an ordinary Scala function to a linear function on demands, in opposite direction.
Lifts an ordinary Scala function to a linear function on demands, in opposite direction.
Releases a resource using the release
function registered during resource acquisition.
Releases a resource using the release
function registered during resource acquisition.
Concrete methods
Performs a (potentially) effectful operation on a resource, producing some output.
Performs a (potentially) effectful operation on a resource, producing some output.
- Type Params
- A
additional parameter of the operation
- B
additional output of the operation
- R
type of the resource
- Value Params
- f
the effectful operation
Releases a resource using the given function. The release
function previously registered during resource
acquisition is not used.
Releases a resource using the given function. The release
function previously registered during resource
acquisition is not used.
- Type Params
- A
additional parameter of the release function
- B
additional data produced by the release function
- R
type of the resource
- Value Params
- f
the release function
Transforms a resource into a resource of (possibly) different type.
Transforms a resource into a resource of (possibly) different type.
- Type Params
- A
additional parameter of the transformation
- B
additional output of the transformation
- R
type of the input resource
- S
type of the output resource
- Value Params
- f
the transformation function. It receives the input resource and additional input of type A. It returns the new resource and additional output of type B.
- release
called to release the new resource in case of a crash.
None
means no cleanup is needed
Acquires a resource of type R. Might fail with an error of type E.
Acquires a resource of type R. Might fail with an error of type E.
- Type Params
- A
parameters of the
acquire
function- B
additional data produced by acquiring the resource
- E
type of the error
- R
type of the resource
- Value Params
- release
called to release the resource in case of a crash.
None
means no cleanup is needed
Transforms a resource into a resource of (possibly) different type. Might fail with an error of type E.
Transforms a resource into a resource of (possibly) different type. Might fail with an error of type E.
- Type Params
- A
additional parameter of the transformation
- B
additional output of the transformation
- E
type of the error
- R
type of the input resource
- S
type of the output resource
- Value Params
- f
the transformation function. It receives the input resource and additional input of type A. It returns either an error of type E or the new resource and additional output of type B. In case the transformation results in an error, the original resource is ''not'' released automatically— the passing of the original resource
R
to the transformation functionf
indicates transfer of responsibility for the resource to the functionf
.- release
called to release the new resource in case of a crash.
None
means no cleanup is needed
Inherited methods
Crashes the program. Use only for irrecoverable errors.
Crashes the program. Use only for irrecoverable errors.
Recoverable errors should be expressed in function signature and handled appropriately.
Done in the input is the trigger to crash. Done in the output is an obligation to propagate the crash. A in the input allows to consume any unhandled resources. B in the output allows to fulfill any obligation to produce resources.
- Inherited from
- CrashDSL
Factor out the factor A
on the left of both summands.
Factor out the factor A
on the left of both summands.
- Inherited from
- CoreDSL
Factor out the factor C
on the right of both summands.
Factor out the factor C
on the right of both summands.
- Inherited from
- CoreDSL
Signals (in the negative direction) when it is known which side of the choice (A |&| B
) has been chosen.
Signals (in the negative direction) when it is known which side of the choice (A |&| B
) has been chosen.
- Inherited from
- CoreDSL
Signals when it is decided whether A |+| B
actually contains the left side or the right side.
Signals when it is decided whether A |+| B
actually contains the left side or the right side.
- Inherited from
- CoreDSL
Hides one level of a recursive type definition.
Hides one level of a recursive type definition.
- Inherited from
- CoreDSL
Races the two Ping signals. Produces left if the first signal wins and right if the second signal wins. It is biased to the left: if both signals have arrived by the time of inquiry, returns left.
Races the two Pong signals (traveling from right to left). Chooses left if the first signal wins and right if the second signal wins. It is biased to the left: if both signals have arrived by the time of inquiry, chooses left.