CoreLib

class CoreLib[DSL <: CoreDSL](val dsl: DSL)
Companion
object
class Object
trait Matchable
class Any

Type members

Classlikes

trait Affine[A]
Companion
object
object Affine
Companion
class
trait BiExternalizer[F[_, _]]
trait Bifunctor[F[_, _]]

Witnesses that F is a bifunctor (covariant in both variables).

Companion
object
object Bifunctor
Companion
class
class BimapSyntax[F[_, _], A, B](self: A -⚬ B)
object Bool
trait Comonad[F[_]]
trait Comonoid[A] extends Cosemigroup[A] with Affine[A]
trait Comparable[A, B]
object Compared
trait ContraExternalizer[F[_]]

Contravariant functor from category -⚬ to the category => of Scala functions. It takes a morphism A -⚬ B internal to the DSL and maps it to a morphism F[B] => F[A] in the meta language (Scala), i.e. external to the DSL.

Companion
object
Companion
class
trait ContraFunctor[F[_]]

Witnesses that F is a contravariant endofunctor on the category -⚬.

trait Cosemigroup[A]
object Delayed
trait Dual[A, B]

Evidence that A flowing in one direction is equivalent to to B flowing in the opposite direction. It must hold that

       ┏━━━━━┓                         ┏━━━━━┓
       ┞─┐ r ┃                         ┃  l  ┞─┐
       ╎A│ I ┃                         ┃  I  ╎B│
       ┟─┘ n ┃                         ┃  n  ┟─┘
 ┏━━━━━┫   v ┃     ┏━━━━━━━━━┓         ┃  v  ┣━━━━━┓     ┏━━━━━━━━━┓
 ┃  l  ┞─┐ e ┃     ┞─┐       ┞─┐       ┃  e  ┞─┐ r ┃     ┞─┐       ┞─┐
 ┃  I  ╎B│ r ┃  =  ╎A│ id[A] ╎A│       ┃  r  ╎A│ I ┃  =  ╎B│ id[B] ╎B│
 ┃  n  ┟─┘ t ┃     ┟─┘       ┟─┘       ┃  t  ┟─┘ n ┃     ┟─┘       ┟─┘
 ┃  v  ┣━━━━━┛     ┗━━━━━━━━━┛         ┗━━━━━┫   v ┃     ┗━━━━━━━━━┛
 ┃  e  ┞─┐                                   ┞─┐ e ┃
 ┃  r  ╎A│                                   ╎B│ r ┃
 ┃  t  ┟─┘                                   ┟─┘ t ┃
 ┗━━━━━┛                                     ┗━━━━━┛
Companion
object
object Dual
Companion
class
trait Dual1[F[_], G[_]]

Evidence that if A is dual to B, then F[A] is dual to G[B].

trait Externalizer[F[_]]

Functor from category -⚬ to the category => of Scala functions. It takes a morphism A -⚬ B internal to the DSL and maps it to a morphism F[A] => F[B] in the meta language (Scala), i.e. external to the DSL.

Companion
object
object Externalizer
Companion
class
class FocusedBi[F[_, _], B1, B2](f: F[B1, B2])(F: BiExternalizer[F])
class FocusedCo[F[_], B](f: F[B])(F: Externalizer[F])

Focused on B in F[B], where B is in a covariant position.

class FocusedContra[F[_], B](f: F[B])(F: ContraExternalizer[F])

Focused on B in the output F[B] of linear function A -⚬ F[B], where B is in a contravariant position.

class FocusedOnChoiceCo[F[_], B1, B2](f: FocusedCo[F, B1 |&| B2])
class FocusedOnChoiceContra[A, F[_], B1, B2](f: FocusedContra[F, B1 |&| B2])
class FocusedOnDoneTimesCo[F[_], B2](f: FocusedCo[F, Done |*| B2])(j: Positive[B2])
class FocusedOnPairCo[F[_], B1, B2](f: FocusedCo[F, B1 |*| B2])
class FocusedOnPairContra[A, F[_], B1, B2](f: FocusedContra[F, B1 |*| B2])
class FocusedOnPlusCo[F[_], B1, B2](f: FocusedCo[F, B1 |+| B2])
class FocusedOnPlusContra[A, F[_], B1, B2](f: FocusedContra[F, B1 |+| B2])
class FocusedOnTimesDoneCo[F[_], B1](f: FocusedCo[F, B1 |*| Done])(j: Positive[B1])
trait Functor[F[_]]

Witnesses that F is a covariant endofunctor on the category -⚬.

trait Getter[S, A]
Companion
object
object Getter
Companion
class
object Junction
object LList
trait Lens[S, A] extends Getter[S, A]
Companion
object
object Lens
Companion
class
class LinearFunctionOps[A, B](self: A -⚬ B)
class LinearFunctionToPairOps[A, B1, B2](self: A -⚬ B1 |*| B2)
class LinearFunctionToPlusOps[A, B1, B2](self: A -⚬ B1 |+| B2)
object Maybe
trait Monad[F[_]]
trait Monoid[A] extends Semigroup[A]
Companion
object
object Monoid
Companion
class
object Multiple
trait NAffine[A]
Companion
object
object NAffine
Companion
class
trait NComonoid[A] extends Cosemigroup[A] with NAffine[A]

A Comonoid whose counit can be chained before a signal flowing in the '''N'''egative direction (Need), effectively taking on the responsibility to await completion of some computation.

The dual of PMonoid.

trait NMonoid[A] extends Semigroup[A]

A weaker version of Monoid whose unit creates a liability - a signal traveling in the '''N'''egative direction (Need) that eventually needs to be awaited.

Its dual is PComonoid.

object Optionally
trait PAffine[A]
Companion
object
object PAffine
Companion
class
trait PComonoid[A] extends Cosemigroup[A] with PAffine[A]

A weaker version of Comonoid whose counit cannot discard the input completely, but can reduce it to a signal traveling in the '''P'''ositive direction (Done) that eventually needs to be awaited.

The dual of NMonoid.

object PMaybe
trait PMonoid[A] extends Semigroup[A]

A Monoid whose unit can be chained after a signal flowing in the '''P'''ositive direction (Done), effectively taking on the responsibility to wait for completion of some computation.

Its dual is NComonoid.

object PUnlimited
trait Semigroup[A]
object Signaling
trait Transportive[F[_]] extends Functor[F]
object Unlimited
object |&|
object |*|
object |+|

Types

opaque type Bool
opaque type Delayed[A]

A type alias expressing the ''intent'' that A is delayed (in some sense) until a signal (Need) is received. Equivalent to Done =⚬ A, but the formulation as Need |*| A does not rely on the more powerful concept of ''function types'' (internal hom objects), i.e. does not require ClosedDSL.

type Id[A] = A
opaque type LList[T]
opaque type Maybe[A]
opaque type Multiple[A]

Zero or more instances of A. The exact multiplicity is determined by the producer.

Similar to LList, but unlike LList, the producer of Multiple is not required to unveil the elements sequentially. There are many different representations (in fact an infinite number) of the same sequence of elements of type A as Multiple[A], while there is only one representation of that sequence as LList[A].

opaque type Optionally[A]
opaque type PMaybe[A]
opaque type PUnlimited[A]
opaque type Unlimited[A]

Unlimited supply of As. The consumer chooses how many As to consume.

Value members

Methods

def IX[A, B, C]: A |*| B |*| C -⚬ A |*| C |*| B
def IXI[A, B, C, D]: A |*| B |*| C |*| D -⚬ A |*| C |*| B |*| D
def XI[A, B, C]: A |*| B |*| C -⚬ B |*| A |*| C
def awaitChooseL[A, B](A: Negative[A]): A |&| B -⚬ Need |*| A

Chooses the left alternative A of the choice A |&| B, but only after the Need signal from the first out-port arrives. Until then, the producer of A |&| B will see it as undecided. This is different from chooseL[A, B] > awaitNegFst[A], in which the producer of A |&| B knows immediately that the left side is chosen.

def awaitChooseR[A, B](B: Negative[B]): A |&| B -⚬ Need |*| B

Analogous to awaitChooseL, but chooses the right side.

def awaitInjectL[A, B](A: Positive[A]): Done |*| A -⚬ A |+| B

Injects A from the the second in-port to the left side of the |+| in the out-port, but only after the Done signal from the first in-port arrives. That means that the consumer of A |+| B will see it as undecided until the Done signal arrives. This is different from awaitPosFst[A] > injectL[A, B], in which the consumer of A |+| B knows immediately that it is the left case.

This is a convenience method on top of injectLWhenDone that which absorbs the Done signal using the given Junction.Positive.

def awaitInjectR[A, B](B: Positive[B]): Done |*| B -⚬ A |+| B

Analogous to joinInjectL, but injects to the right.

def awaitNegFst[A](A: Negative[A]): A -⚬ Need |*| A
def awaitNegSnd[A](A: Negative[A]): A -⚬ A |*| Need
def awaitPosChooseL[A, B](A: Positive[A]): Done |*| A |&| B -⚬ A

Analogous to awaitChooseL, but awaits a positive (i.e. Done) signal.

def awaitPosChooseR[A, B](B: Positive[B]): Done |*| A |&| B -⚬ B

Analogous to awaitChooseR, but awaits a positive (i.e. Done) signal.

def awaitPosFst[A](A: Positive[A]): Done |*| A -⚬ A
def awaitPosSnd[A](A: Positive[A]): A |*| Done -⚬ A
def chooseLWhenDone[A, B]: Done |*| A |&| B -⚬ Done |*| A
def chooseRWhenDone[A, B]: Done |*| A |&| B -⚬ Done |*| B
def compareBy[A, B, K1, K2](aKey: Getter[A, K1], bKey: Getter[B, K2])(`evidence$7`: PComonoid[K1], `evidence$8`: Positive[K1], `evidence$9`: PComonoid[K2], `evidence$10`: Positive[K2], cmp: Comparable[K1, K2]): A |*| B -⚬ Compared[A, B]
def delayUsing[A](f: Done -⚬ Done)(A: Positive[A]): A -⚬ A
def delayUsing[A](f: Need -⚬ Need)(A: Negative[A]): A -⚬ A
def discardFst[A, B](A: Comonoid[A]): A |*| B -⚬ B
def discardSnd[A, B](B: Comonoid[B]): A |*| B -⚬ A
def dualRec[F[_], G[_]](ev: Dual1[F, G]): Dual[Rec[F], Rec[G]]

If F[A] is dual to G[B] for all dual pairs A, B, then Rec[F] is dual to Rec[G].

def dualSymmetric[A, B](ev: Dual[A, B]): Dual[B, A]
def getFst[A, B](A: Cosemigroup[A]): A |*| B -⚬ A |*| A |*| B
def getSnd[A, B](B: Cosemigroup[B]): A |*| B -⚬ B |*| A |*| B
def injectLWhenNeed[A, B]: Need |*| A -⚬ Need |*| A |+| B
def injectRWhenNeed[A, B]: Need |*| B -⚬ Need |*| A |+| B
def lInvert[A, B](ev: Dual[A, B]): One -⚬ B |*| A
def lInvertChoice[A, B, Ȧ, Ḃ](lInvertA: One -⚬ Ȧ |*| A, lInvertB: One -⚬|*| B): One -⚬ Ȧ |&||*| A |+| B
def lInvertPair[A, B, Ȧ, Ḃ](lInvertA: One -⚬ Ȧ |*| A, lInvertB: One -⚬|*| B): One -⚬ Ȧ |*||*| A |*| B
def lInvertRec[F[_], G[_]](lInvertSub: [x, y] => (x$1: One -⚬ x |*| y) => One -⚬ F[x] |*| G[y]): One -⚬ Rec[F] |*| Rec[G]
def matchingChoiceLR[A, B, C, D]: A |+| B |*| C |&| D -⚬ A |*| C |+| B |*| D

From the choice ''available'' on the right (C |&| D), choose the one corresponding to the choice ''made'' on the left (A |+| B): if on the left there is A, choose C, if on the left thre is B, choose D.

def matchingChoiceRL[A, B, C, D]: A |&| B |*| C |+| D -⚬ A |*| C |+| B |*| D

From the choice ''available'' on the left (A |&| B), choose the one corresponding to the choice ''made'' on the right (C |+| D): if on the right there is C, choose A, if on the right there is D, choose B.

def parFromOne[A, B](f: One -⚬ A, g: One -⚬ B): One -⚬ A |*| B
def parToOne[A, B](f: A -⚬ One, g: B -⚬ One): A |*| B -⚬ One
def rInvert[A, B](ev: Dual[A, B]): A |*| B -⚬ One
def rInvertEither[A, B, Ȧ, Ḃ](rInvertA: A |*| Ȧ -⚬ One, rInvertB: B |*|-⚬ One): A |+| B |*| Ȧ |&|-⚬ One
def rInvertPair[A, B, Ȧ, Ḃ](rInvertA: A |*| Ȧ -⚬ One, rInvertB: B |*|-⚬ One): A |*| B |*| Ȧ |*|-⚬ One
def rInvertRec[F[_], G[_]](rInvertSub: [x, y] => (x$1: x |*| y -⚬ One) => F[x] |*| G[y] -⚬ One): Rec[F] |*| Rec[G] -⚬ One
def race[A, B](A: Positive[A], B: Positive[B]): A |*| B -⚬ A |*| B |+| A |*| B
def race[A, B, C](caseFstWins: A |*| B -⚬ C, caseSndWins: A |*| B -⚬ C)(`evidence$1`: Positive[A], `evidence$2`: Positive[B]): A |*| B -⚬ C
def raceAgainstL[A](A: Positive[A]): Done |*| A -⚬ A |+| A
def raceAgainstR[A](A: Positive[A]): A |*| Done -⚬ A |+| A
def raceSignaledOrNot[A](A: Positive[A]): A -⚬ A |+| A
def rec2[A, B, C, D](f: (A -⚬ B, C -⚬ D) => A -⚬ B, g: (A -⚬ B, C -⚬ D) => C -⚬ D): (A -⚬ B, C -⚬ D)

Creates a pair of mutually recursive functions.

def select[A, B](A: Negative[A], B: Negative[B]): A |*| B |&| A |*| B -⚬ A |*| B
def select[Z, A, B](caseFstWins: Z -⚬ A |*| B, caseSndWins: Z -⚬ A |*| B)(`evidence$3`: Negative[A], `evidence$4`: Negative[B]): Z -⚬ A |*| B
def selectAgainstL[A](A: Negative[A]): A |&| A -⚬ Need |*| A
def selectAgainstR[A](A: Negative[A]): A |&| A -⚬ A |*| Need
def selectSignaledOrNot[A](A: Negative[A]): A |&| A -⚬ A
def subordinateFst[A, B, C, D]: A |*| B |&| C |*| D -⚬ A |+| C |*| B |&| D

Present a choice between two pairs ((A |*| B) |&| (C |*| D)) as a choice (B |&| D) between the second parts of the respective pairs and on the side provide the other part of the chosen input pair, i.e. either A or C (A |+| C).

def subordinateSnd[A, B, C, D]: A |*| B |&| C |*| D -⚬ A |&| C |*| B |+| D

Present a choice between two pairs ((A |*| B) |&| (C |*| D)) as a choice (A |&| C) between the first parts of the respective pairs and on the side provide the other part of the chosen input pair, i.e. either B or D (B |+| D).

def testBy[A, B, K](aKey: Getter[A, K], bKey: Getter[B, K], pred: K |*| K -⚬ Bool)(`evidence$5`: Cosemigroup[K], `evidence$6`: Positive[K]): A |*| B -⚬ A |*| B |+| A |*| B

Fields

val dsl: DSL

Implicits

Implicits

implicit def choiceEitherDuality[A, B, Ȧ, Ḃ](a: Dual[A, Ȧ], b: Dual[B, Ḃ]): Dual[A |&| B, Ȧ |+| Ḃ]
implicit def comonoidUnlimited[A]: Comonoid[Unlimited[A]]
implicit def doneNeedDuality: Dual[Done, Need]
implicit def eitherChoiceDuality[A, B, Ȧ, Ḃ](a: Dual[A, Ȧ], b: Dual[B, Ḃ]): Dual[A |+| B, Ȧ |&| Ḃ]
implicit def fst[B]: Transportive[[x] =>> x |*| B]
implicit val idFunctor: Transportive[Id]
implicit def monoidMultiple[A]: Monoid[Multiple[A]]
implicit def oneSelfDual: Dual[One, One]
implicit val pairBifunctor: Bifunctor[|*|]
implicit def pairDuality[A, B, Ȧ, Ḃ](a: Dual[A, Ȧ], b: Dual[B, Ḃ]): Dual[A |*| B, Ȧ |*| Ḃ]
implicit def snd[A]: Transportive[[x] =>> A |*| x]