InvertDSL

libretto.InvertDSL
trait InvertDSL extends ClosedDSL

Attributes

Graph
Supertypes
trait ClosedDSL
trait CoreDSL
class Object
trait Matchable
class Any
Known subtypes
trait Scaletto
object FreeScaletto.type

Members list

Concise view

Type members

Classlikes

implicit class DemandExprOps[B](expr: $[-[B]])

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Inherited classlikes

trait $Ops

Attributes

Inherited from:
CoreDSL
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Affine

Attributes

Inherited from:
CoreDSL
Graph
Supertypes
class Object
trait Matchable
class Any
trait Affine[A]

Attributes

Inherited from:
CoreDSL
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Comonoid[A]

Attributes

Inherited from:
ClosedDSL
Graph
Supertypes
class Object
trait Matchable
class Any
object Comonoid

Attributes

Inherited from:
CoreDSL
Graph
Supertypes
class Object
trait Matchable
class Any
trait Comonoid[A] extends Cosemigroup[A] with Affine[A]

Attributes

Inherited from:
CoreDSL
Graph
Supertypes
trait Affine[A]
trait Cosemigroup[A]
class Object
trait Matchable
class Any

Attributes

Inherited from:
CoreDSL
Graph
Supertypes
class Object
trait Matchable
class Any
trait Cosemigroup[A]

Attributes

Inherited from:
CoreDSL
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Comonoid[A]
trait NComonoid[A]
trait PComonoid[A]
trait FunExprOps extends $Ops

Attributes

Inherited from:
ClosedDSL
Graph
Supertypes
trait $Ops
class Object
trait Matchable
class Any
trait LambdaOps

Attributes

Inherited from:
CoreDSL
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Inherited from:
ClosedDSL
Graph
Supertypes
trait LambdaOps
class Object
trait Matchable
class Any

Types

type -[A]

-[A] is a demand for A.

-[A] is a demand for A.

Inverts the flow of information: whatever travels through A in one direction, travels through -[A] in the opposite direction.

Attributes

override type =⚬[A, B] = -[A] |*| B

Linear function as data, that is, one that can be part of an input or output of a linear function (-⚬). While A -⚬ B is a morphism in a category, A =⚬ B is an object called the internal hom of A and B in a closed monoidal category.

Linear function as data, that is, one that can be part of an input or output of a linear function (-⚬). While A -⚬ B is a morphism in a category, A =⚬ B is an object called the internal hom of A and B in a closed monoidal category.

Attributes

Inherited types

type $[A]

The type of auxiliary placeholder variables used in construction of λ-expressions.

The type of auxiliary placeholder variables used in construction of λ-expressions.

Attributes

Inherited from:
CoreDSL
type -⚬[A, B]

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.

Attributes

Inherited from:
CoreDSL
type Done

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.)

Attributes

Inherited from:
CoreDSL

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

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

Attributes

Inherited from:
CoreDSL
type Need

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.)

Attributes

Inherited from:
CoreDSL
type NoCaptureException <: Throwable

Attributes

Inherited from:
ClosedDSL
type NotLinearException <: Throwable

Attributes

Inherited from:
CoreDSL
type One

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

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

Attributes

Inherited from:
CoreDSL
type Ping

Signal that travels in the direction of -⚬, i.e. the positive direction. [Unlike Done, it cannot be the only handle to an effectful computation. As such, it can be ignored, e.g. as the losing contestant in racePair.

Signal that travels in the direction of -⚬, i.e. the positive direction. [Unlike Done, it cannot be the only handle to an effectful computation. As such, it can be ignored, e.g. as the losing contestant in racePair.

Attributes

Inherited from:
CoreDSL
type Pong

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.

Attributes

Inherited from:
CoreDSL

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

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

Attributes

Inherited from:
CoreDSL
type Rec[F[_]]

Attributes

Inherited from:
CoreDSL
type UnboundVariablesException <: Throwable

Attributes

Inherited from:
CoreDSL
type Zero

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

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

Attributes

Inherited from:
CoreDSL
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.

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.

Attributes

Inherited from:
CoreDSL
type |*|[A, B]

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

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

Attributes

Inherited from:
CoreDSL
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.

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.

Attributes

Inherited from:
CoreDSL
type [A, B] = A |+| B

Alias for |+|.

Alias for |+|.

Attributes

Inherited from:
CoreDSL
type [A, B] = A |*| B

Alias for |*|.

Alias for |*|.

Attributes

Inherited from:
CoreDSL

Value members

Abstract methods

def backvert[A]: A |*| -[A] -⚬ One
 ┏━━━━━━━━━━━┓
 ┞────┐      ┃
 ╎  A │┄┄┐   ┃
 ┟────┘  ┆   ┃
 ┃       ┆   ┃
 ┞────┐  ┆   ┃
 ╎-[A]│←┄┘   ┃
 ┟────┘      ┃
 ┗━━━━━━━━━━━┛

Attributes

def distributeInversion[A, B]: -[A |*| B] -⚬ -[A] |*| -[B]
 ┏━━━━━━━━━━━┓
 ┃           ┞────┐
 ┞────┐      ╎-[A]│
 ╎ ⎡A⎤│      ┟────┘
 ╎-⎢⊗⎥│      ┃
 ╎ ⎣B⎦│      ┞────┐
 ┟────┘      ╎-[B]│
 ┃           ┟────┘
 ┗━━━━━━━━━━━┛

Attributes

def factorOutInversion[A, B]: -[A] |*| -[B] -⚬ -[A |*| B]
 ┏━━━━━━━━━━━┓
 ┞────┐      ┃
 ╎-[A]│      ┞────┐
 ┟────┘      ╎ ⎡A⎤│
 ┃           ╎-⎢⊗⎥│
 ┞────┐      ╎ ⎣B⎦│
 ╎-[B]│      ┟────┘
 ┟────┘      ┃
 ┗━━━━━━━━━━━┛

Attributes

def forevert[A]: One -⚬ -[A] |*| A
 ┏━━━━━━┓
 ┃      ┞────┐
 ┃   ┌┄┄╎-[A]│
 ┃   ┆  ┟────┘
 ┃   ┆  ┃
 ┃   ┆  ┞────┐
 ┃   └┄→╎  A │
 ┃      ┟────┘
 ┗━━━━━━┛

Attributes

Concrete methods

def contrapositive[A, B](f: A -⚬ B): -[B] -⚬ -[A]
override def curry[A, B, C](f: A |*| B -⚬ C): A -⚬ B =⚬ C

Attributes

Definition Classes
def demand[A]: One -⚬ -[A] |*| A

Creates a demand on the first out-port, channeling the provided resource to the second out-port. Alias for forevert.

Creates a demand on the first out-port, channeling the provided resource to the second out-port. Alias for forevert.

Attributes

def demandChoice[A, B]: -[A] |+| -[B] -⚬ -[A |&| B]

Converts an obligation to handle either demand to an obligation to supply a choice. Alias for factorInversionOutOf_|+|.

Converts an obligation to handle either demand to an obligation to supply a choice. Alias for factorInversionOutOf_|+|.

Attributes

def demandChosen[A, B]: -[A |&| B] -⚬ -[A] |+| -[B]

Converts a demand for choice to a demand of the chosen side. Alias for distributeInversionInto_|&amp;|.

Converts a demand for choice to a demand of the chosen side. Alias for distributeInversionInto_|&amp;|.

Attributes

def demandEither[A, B]: -[A] |&| -[B] -⚬ -[A |+| B]

Converts choice of demands to demand of either. Alias for factorInversionOutOf_|&amp;|.

Converts choice of demands to demand of either. Alias for factorInversionOutOf_|&amp;|.

Attributes

def demandSeparately[A, B]: -[A |*| B] -⚬ -[A] |*| -[B]

Attributes

def demandTogether[A, B]: -[A] |*| -[B] -⚬ -[A |*| B]

Alias for factorOutInversion.

Alias for factorOutInversion.

Attributes

def die[A]: -[-[A]] -⚬ A

Double-inversion elimination.

Double-inversion elimination.

Attributes

def dii[A]: A -⚬ -[-[A]]

Double-inversion introduction.

Double-inversion introduction.

Attributes

def distributeInversionInto_|&|[A, B]: -[A |&| B] -⚬ -[A] |+| -[B]
def distributeInversionInto_|+|[A, B]: -[A |+| B] -⚬ -[A] |&| -[B]

Alias for die.

Alias for die.

Attributes

Alias for dii.

Alias for dii.

Attributes

override def eval[A, B]: A =⚬ B |*| A -⚬ B

Attributes

Definition Classes
def factorInversionOutOf_|&|[A, B]: -[A] |&| -[B] -⚬ -[A |+| B]
def factorInversionOutOf_|+|[A, B]: -[A] |+| -[B] -⚬ -[A |&| B]
def invertClosure[A, B]: -[A =⚬ B] -⚬ B =⚬ A
override def out[A, B, C](f: B -⚬ C): A =⚬ B -⚬ A =⚬ C

Map the output of a function object.

Map the output of a function object.

Attributes

Definition Classes
def packDemand[F[_]]: -[F[Rec[F]]] -⚬ -[Rec[F]]
def supply[A]: A |*| -[A] -⚬ One

Uses the resource from the first in-port to satisfy the demand from the second in-port. Alias for backvert.

Uses the resource from the first in-port to satisfy the demand from the second in-port. Alias for backvert.

Attributes

def toChoiceOfDemands[A, B]: -[A |+| B] -⚬ -[A] |&| -[B]

Converts demand for either to a choice of which side to supply. Alias for distributeInversionInto_|+|.

Converts demand for either to a choice of which side to supply. Alias for distributeInversionInto_|+|.

Attributes

def unContrapositive[A, B](f: -[A] -⚬ -[B]): B -⚬ A
def unInvertClosure[A, B]: A =⚬ B -⚬ -[B =⚬ A]
def unpackDemand[F[_]]: -[Rec[F]] -⚬ -[F[Rec[F]]]

Inherited methods

def andThen[A, B, C](f: A -⚬ B, g: B -⚬ C): A -⚬ C

Attributes

Inherited from:
CoreDSL
def assocLR[A, B, C]: A |*| B |*| C -⚬ A |*| B |*| C

Attributes

Inherited from:
CoreDSL
def assocRL[A, B, C]: A |*| B |*| C -⚬ A |*| B |*| C

Attributes

Inherited from:
CoreDSL
def choice[A, B, C](caseLeft: A -⚬ B, caseRight: A -⚬ C): A -⚬ B |&| C

Attributes

Inherited from:
CoreDSL
def chooseL[A, B]: A |&| B -⚬ A

Attributes

Inherited from:
CoreDSL
def chooseLOnPong[A, B]: A |&| B -⚬ Pong |*| A

Attributes

Inherited from:
CoreDSL
def chooseR[A, B]: A |&| B -⚬ B

Attributes

Inherited from:
CoreDSL
def chooseROnPong[A, B]: A |&| B -⚬ Pong |*| B

Attributes

Inherited from:
CoreDSL
def coDistributeL[A, B, C]: A |*| B |&| A |*| C -⚬ A |*| B |&| C

Inverse of coFactorL.

Inverse of coFactorL.

Attributes

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

Inverse of coFactorR.

Inverse of coFactorR.

Attributes

Inherited from:
CoreDSL
def coFactorL[A, B, C]: A |*| B |&| C -⚬ A |*| B |&| A |*| C

Attributes

Inherited from:
CoreDSL
def coFactorR[A, B, C]: A |&| B |*| C -⚬ A |*| C |&| B |*| C

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
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.

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

Attributes

Inherited from:
CoreDSL
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.

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

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
def either[A, B, C](caseLeft: A -⚬ C, caseRight: B -⚬ C): A |+| B -⚬ C

Attributes

Inherited from:
CoreDSL
def elimFst[A, B](f: A -⚬ One): A |*| B -⚬ B

Attributes

Inherited from:
CoreDSL
def elimFst[B]: One |*| B -⚬ B

Attributes

Inherited from:
CoreDSL
def elimSnd[A, B](f: B -⚬ One): A |*| B -⚬ A

Attributes

Inherited from:
CoreDSL
def elimSnd[A]: A |*| One -⚬ A

Attributes

Inherited from:
CoreDSL
def factorL[A, B, C]: A |*| B |+| A |*| C -⚬ A |*| B |+| C

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

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

Attributes

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

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

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

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
def forkMap[A, B](f: Done -⚬ A, g: Done -⚬ B): Done -⚬ A |*| B

Attributes

Inherited from:
CoreDSL
def forkMapNeed[A, B](f: A -⚬ Need, g: B -⚬ Need): A |*| B -⚬ Need

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
def fst[A, B, C](f: A -⚬ B): A |*| C -⚬ B |*| C

Attributes

Inherited from:
CoreDSL
def id[A]: A -⚬ A

Attributes

Inherited from:
CoreDSL
def injectL[A, B]: A -⚬ A |+| B

Attributes

Inherited from:
CoreDSL
def injectLOnPing[A, B]: Ping |*| A -⚬ A |+| B

Attributes

Inherited from:
CoreDSL
def injectR[A, B]: B -⚬ A |+| B

Attributes

Inherited from:
CoreDSL
def injectROnPing[A, B]: Ping |*| B -⚬ A |+| B

Attributes

Inherited from:
CoreDSL
def introFst[A, X](f: One -⚬ X): A -⚬ X |*| A

Attributes

Inherited from:
CoreDSL
def introFst[B]: B -⚬ One |*| B

Attributes

Inherited from:
CoreDSL
def introSnd[A, X](f: One -⚬ X): A -⚬ A |*| X

Attributes

Inherited from:
CoreDSL
def introSnd[A]: A -⚬ A |*| One

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
def joinMap[A, B](f: A -⚬ Done, g: B -⚬ Done): A |*| B -⚬ Done

Attributes

Inherited from:
CoreDSL
def joinMapNeed[A, B](f: Need -⚬ A, g: Need -⚬ B): Need -⚬ A |*| B

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

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).

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│
 ┃      ┟────┘
 ┗━━━━━━┛

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
def notifyChoice[A, B]: Pong |*| A |&| B -⚬ A |&| B

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.

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
def notifyEither[A, B]: A |+| B -⚬ Ping |*| A |+| B

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.

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
def obj[A, B](f: A -⚬ B): One -⚬ A =⚬ B

Turn a function into a function object.

Turn a function into a function object.

Attributes

Inherited from:
ClosedDSL
def pack[F[_]]: F[Rec[F]] -⚬ Rec[F]

Hides one level of a recursive type definition.

Hides one level of a recursive type definition.

Attributes

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

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

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).

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│←┄┘   ┃
 ┟────┘      ┃
 ┗━━━━━━━━━━━┛

Attributes

Inherited from:
CoreDSL

Attributes

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 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.

Attributes

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

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

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.

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.

Attributes

Inherited from:
CoreDSL
def snd[A, B, C](f: B -⚬ C): A |*| B -⚬ A |*| C

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL

Attributes

Inherited from:
CoreDSL
def swap[A, B]: A |*| B -⚬ B |*| A

Attributes

Inherited from:
CoreDSL
def uncurry[A, B, C](f: A -⚬ B =⚬ C): A |*| B -⚬ C

Attributes

Inherited from:
ClosedDSL
def unpack[F[_]]: Rec[F] -⚬ F[Rec[F]]

Unpacks one level of a recursive type definition.

Unpacks one level of a recursive type definition.

Attributes

Inherited from:
CoreDSL
def Λ[A, B](using SourcePos)(f: $[A] => $[B]): $[A =⚬ B]

Alias for λ.closure.apply.

Alias for λ.closure.apply.

Attributes

Inherited from:
ClosedDSL

Inherited fields

override val $: FunExprOps

Attributes

Inherited from:
ClosedDSL

Attributes

Inherited from:
ClosedDSL

Implicits

Implicits

final implicit def DemandExprOps[B](expr: $[-[B]]): DemandExprOps[B]