proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Tools.SMC.Internal.Dialogue

Description

Internal module of Proarrow.Tools.SMC: inputs and outputs in dialogue categories, and duals. It exports everything, also what the public module keeps hidden.

Synopsis

Documentation

produce :: forall {k} {p :: CAT k} (a :: SYN k) (d :: Nat). (CompactClosed k, Promonad p, KnownObj a) => TermP p d ('[] :: [(Nat, SYN k)]) (a ':** 'Not a) Source Github #

A new pair of wires, a variable and its dual, from nothing: the unit of the duality. This needs the category to be compact closed.

annihilate :: forall {k} {p :: k +-> k} (a :: SYN k) (d :: Nat) (g1 :: Ctx k) (g2 :: Ctx k). (IsoMix k, MonoidalProfunctor p, KnownObj a, Merge g1 g2) => ConsumerP p d g1 a -> TermP p d g2 a -> TermP p d (Union g1 g2) ('I :: SYN k) Source Github #

Join a dual and its wire into nothing: the counit of the duality, which an isomix category has.

type ConsumerP (p :: k +-> k) (d :: Nat) (g :: Ctx k) (a :: SYN k) = TermP p d g ('Not a) Source Github #

A consumer of a: a term of its negation.

type Consumer (d :: Nat) (g :: Ctx k) (a :: SYN k) = Term d g ('Not a) Source Github #

type CommandP (p :: k +-> k) (d :: Nat) (g :: Ctx k) = TermP p d g ('Not ('I :: SYN k)) Source Github #

A producer and a consumer meeting: a term of the unit of par.

type Command (d :: Nat) (g :: Ctx k) = Term d g ('Not ('I :: SYN k)) Source Github #

type (:##) (a :: SYN k) (b :: SYN k) = 'Not ('Not a ':** 'Not b) infixl 7 Source Github #

Par, the negation of the tensor of the negations, interpreted as Par.

cut :: forall {k} {p :: k +-> k} (a :: SYN k) (d :: Nat) (g1 :: Ctx k) (g2 :: Ctx k). (Dialogue k, MonoidalProfunctor p, KnownObj a, Merge g1 g2) => ConsumerP p d g1 a -> TermP p d g2 a -> CommandP p d (Union g1 g2) Source Github #

A consumer meets a producer: cut k t gives t to k, like applying a continuation.

(|>) :: forall {k} {p :: k +-> k} (a :: SYN k) (d :: Nat) (g1 :: Ctx k) (g2 :: Ctx k). (Dialogue k, MonoidalProfunctor p, KnownObj a, Merge g2 g1) => TermP p d g1 a -> ConsumerP p d g2 a -> CommandP p d (Union g2 g1) infixl 1 Source Github #

cut with the producer first, as System L writes ⟨t | k⟩: t |> k sends t into k.

cont :: forall {k} (d :: Nat) (r :: Ctx k) (a :: SYN k) t cont. (Dialogue k, Binds ((~>) :: CAT k) d r a ('Not ('I :: SYN k)) t cont) => (t -> cont) -> Term d r ('Not a) Source Github #

The binder of System L. cont \x -> c is a term of Not a: it receives an a through the pattern x (see Patterns) and runs the command c with it.

What that a is depends on how the result is used. As a Consumer of a, the a is an input and cont is μ̃: the seller in a shop receives the order, cont \(name, card, replyTo) -> …. As a term of the negative type Not a in its own right, the a is the consumer of an output and cont is μ, Haskell's callCC: a computation Up b receives the consumer of its result, cont \k -> … |> k; a par b :## c receives a consumer for each side, cont \(kb, kc) -> …; and a command, Not I, receives nothing, cont \() -> …. A consumer of a par is a computation, which a nested pair pattern runs to get at the consumers of its sides.

thunk :: forall {k} {p :: CAT k} (n :: SYN k) (d :: Nat) (g :: Ctx k). TermP p d g n -> TermP p d g ('Dn n) Source Github #

Store a term of a negative type as a value: the same morphism at the positive type Dn n, which a bind names instead of running. This is call by push value's thunk, recast to Dn.

force :: forall {k} {p :: CAT k} (n :: SYN k) (d :: Nat) (g :: Ctx k). TermP p d g ('Dn n) -> TermP p d g n Source Github #

A stored term at its negative type again, where a bind runs it. This is call by push value's force, recast from Dn.

classical :: forall {k} {p :: k +-> k} (a :: SYN k) (d :: Nat) (g :: Ctx k). (StarAutonomous k, Profunctor p, KnownObj a) => TermP p d g (Up a) -> TermP p d g a Source Github #

A computation as its value again: double negation elimination, which only a *-autonomous category has. There every type is equivalent to its shift, so the polarities collapse.