CoreDSL

trait CoreDSL
class Object
trait Matchable
class Any
trait ClosedDSL
trait CrashDSL
trait ScalaDSL
trait TimerDSL

Type members

Types

type -⚬[A, B]

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.

type Done

Signal that travels in the direction of -⚬, i.e. the positive direction.

type LTerminus

A black hole that can absorb (i.e. take over the responsibility to await) Need signals, but from which there is no escape.

type Need

Signal that travels in the direction opposite to -⚬, i.e. the negative direction.

type One

No resource. It is the identity element for |*|. There is no flow of information through a One-typed port.

type RTerminus

A black hole that can absorb (i.e. take over the responsibility to await) Done signals, but from which there is no escape.

type Rec[F[_]]
type Zero

Impossible resource. Analogous to Nothing. It is the identity element for |+|.

type |&|[A, B]

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.

type |*|[A, B]

Concurrent pair. Also called a ''tensor product'' or simply ''times''.

type |+|[A, B]

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.

type [A, B] = A |+| B

Alias for |+|.

type [A, B] = A |*| B

Alias for |*|.

Value members

Methods

def andThen[A, B, C](f: A -⚬ B, g: B -⚬ C): A -⚬ C
def assocLR[A, B, C]: A |*| B |*| C -⚬ A |*| B |*| C
def assocRL[A, B, C]: A |*| B |*| C -⚬ A |*| B |*| C
def choice[A, B, C](f: A -⚬ B, g: A -⚬ C): A -⚬ B |&| C
def chooseL[A, B]: A |&| B -⚬ A
def chooseLWhenNeed[A, B]: Need |*| A |&| B -⚬ Need |*| A
def chooseR[A, B]: A |&| B -⚬ B
def chooseRWhenNeed[A, B]: A |&| Need |*| B -⚬ Need |*| B
def coDistributeL[A, B, C]: A |*| B |&| A |*| C -⚬ A |*| B |&| C

Inverse of coFactorL.

def coDistributeR[A, B, C]: A |*| C |&| B |*| C -⚬ A |&| B |*| C

Inverse of coFactorR.

def coFactorL[A, B, C]: A |*| B |&| C -⚬ A |*| B |&| A |*| C
def coFactorR[A, B, C]: A |&| B |*| C -⚬ A |*| C |&| B |*| C
def distributeL[A, B, C]: A |*| B |+| C -⚬ A |*| B |+| A |*| C

Distribute the factor on the left into the summands on the right. Inverse of factorL.

def distributeR[A, B, C]: A |+| B |*| C -⚬ A |*| C |+| B |*| C

Distribute the factor on the right into the summands on the left. Inverse of factorR.

def either[A, B, C](f: A -⚬ C, g: B -⚬ C): A |+| B -⚬ C
def elimFst[B]: One |*| B -⚬ B
def elimFst[A, B](f: A -⚬ One): A |*| B -⚬ B
def elimSnd[A]: A |*| One -⚬ A
def elimSnd[A, B](f: B -⚬ One): A |*| B -⚬ A
def factorL[A, B, C]: A |*| B |+| A |*| C -⚬ A |*| B |+| C

Factor out the factor A on the left of both summands.

def factorR[A, B, C]: A |*| C |+| B |*| C -⚬ A |+| B |*| C

Factor out the factor C on the right of both summands.

def fork[A, B](f: Done -⚬ A, g: Done -⚬ B): Done -⚬ A |*| B
def forkNeed[A, B](f: A -⚬ Need, g: B -⚬ Need): A |*| B -⚬ Need
def id[A]: A -⚬ A
def injectL[A, B]: A -⚬ A |+| B
def injectLWhenDone[A, B]: Done |*| A -⚬ Done |*| A |+| B
def injectR[A, B]: B -⚬ A |+| B
def injectRWhenDone[A, B]: Done |*| B -⚬ A |+| Done |*| B
def introFst[B]: B -⚬ One |*| B
def introFst[A, X](f: One -⚬ X): A -⚬ X |*| A
def introSnd[A]: A -⚬ A |*| One
def introSnd[A, X](f: One -⚬ X): A -⚬ A |*| X
def join[A, B](f: A -⚬ Done, g: B -⚬ Done): A |*| B -⚬ Done
def joinNeed[A, B](f: Need -⚬ A, g: Need -⚬ B): Need -⚬ A |*| B

Reverses the Need signal (flowing in the negative direciton, i.e. against the -⚬ arrow) into a Done signal (flowing in the positive direction, i.e. along the -⚬ arrow).

 ┏━━━━━━┓
 ┃      ┞────┐
 ┃   ┌┄┄╎Need│
 ┃   ┆  ┟────┘
 ┃   ┆  ┃
 ┃   ┆  ┞────┐
 ┃   └┄→╎Done│
 ┃      ┟────┘
 ┗━━━━━━┛
def pack[F[_]]: F[Rec[F]] -⚬ Rec[F]

Hides one level of a recursive type definition.

def par[A, B, C, D](f: A -⚬ B, g: C -⚬ D): A |*| C -⚬ B |*| D

Reverses the Done signal (flowing in the positive direction, i.e. along the -⚬ arrow) into a Need signal (flowing in the negative direciton, i.e. against the -⚬ arrow).

 ┏━━━━━━━━━━━┓
 ┞────┐      ┃
 ╎Done│┄┄┐   ┃
 ┟────┘  ┆   ┃
 ┃       ┆   ┃
 ┞────┐  ┆   ┃
 ╎Need│←┄┘   ┃
 ┟────┘      ┃
 ┗━━━━━━━━━━━┛

Races the two Done signals and - produces left if the first signal wins, in which case it returns the second signal that still has to be awaited; - produces right if the second signal wins, in which case it returns the first signal that still has to be awaited. It is biased to the left: if both signals have arrived by the time of inquiry, returns left.

def rec[A, B](f: A -⚬ B => A -⚬ B): A -⚬ B

Races two Need signals, i.e. signals traveling in the negative direction (i.e. opposite the -⚬ arrow). Based on which Need signal from the out-port wins the race, selects one of the two Need signals from the in-port: - If the first signal from the out-port wins the race, selects the left signal from the in-port and pipes to it the remaining (i.e. the right) signal from the out-port. - If the second signal from the out-port wins the race, selects the right signal from the in-port and pipes to it the reamining (i.e. the left) signal from the out-port. It is biased to the left: if both signals from the out-port have arrived by the time of inquiry, selects the left signal from the in-port.

def signalChoice[A, B]: Need |*| A |&| B -⚬ A |&| B

Signals (in the negative direction) when it is known which side of the choice (A |&| B) has been chosen.

def signalEither[A, B]: A |+| B -⚬ Done |*| A |+| B

Signals when it is decided whether A |+| B actually contains the left side or the right side.

def swap[A, B]: A |*| B -⚬ B |*| A
def unpack[F[_]]: Rec[F] -⚬ F[Rec[F]]

Unpacks one level of a recursive type definition.