proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Tools.SMC.Internal.Additive

Description

Internal module of Proarrow.Tools.SMC: the additives. It exports everything, also what the public module keeps hidden.

Synopsis

Documentation

with :: forall {k} (a :: SYN k) (b :: SYN k) (d :: Nat) (g1 :: Ctx k) (g2 :: Ctx k). (HasBinaryProducts k, Thin (Union g1 g2) g1, Thin (Union g1 g2) g2) => Term d g1 a -> Term d g2 b -> Term d (Union g1 g2) (a ':&& b) Source Github #

Both of two alternatives over the same variables: the product. This needs products.

exl :: forall {k} {p :: k +-> k} (a :: SYN k) (b :: SYN k) (d :: Nat) (g :: Ctx k). (HasBinaryProducts k, Profunctor p, KnownObj a, KnownObj b) => TermP p d g (a ':&& b) -> TermP p d g a Source Github #

The first alternative of a product.

exr :: forall {k} {p :: k +-> k} (a :: SYN k) (b :: SYN k) (d :: Nat) (g :: Ctx k). (HasBinaryProducts k, Profunctor p, KnownObj a, KnownObj b) => TermP p d g (a ':&& b) -> TermP p d g b Source Github #

The second alternative of a product.

absorb :: forall {k} {p :: k +-> k} (s :: SYN k) (d :: Nat) (g :: Ctx k). (HasTerminalObject k, Profunctor p, KnownObj s) => TermP p d g s -> TermP p d g ('Top :: SYN k) Source Github #

Use up a term into the unit of the product.

inl :: forall {k} (a :: SYN k) (b :: SYN k) (d :: Nat) (g :: Ctx k) (p :: k +-> k). (Profunctor p, HasBinaryCoproducts k, KnownObj a, KnownObj b) => TermP p d g a -> TermP p d g (a ':|| b) Source Github #

The left injection into a coproduct.

inr :: forall {k} (a :: SYN k) (b :: SYN k) (d :: Nat) (g :: Ctx k) (p :: k +-> k). (Profunctor p, HasBinaryCoproducts k, KnownObj a, KnownObj b) => TermP p d g b -> TermP p d g (a ':|| b) Source Github #

The right injection into a coproduct.

class Interp s ~ Interp (a ':|| b) => Sum (s :: SYN k) (a :: SYN k) (b :: SYN k) Source Github #

A sum with components a and b: either a :|| b or a coproduct embedded by F.

Instances

Instances details
s ~ (a ':|| b) => Sum (s :: SYN k) (a :: SYN k) (b :: SYN k) Source Github # 
Instance details

Defined in Proarrow.Tools.SMC.Internal.Additive

(z ~ (x || y), a ~ 'F x, b ~ 'F y) => Sum ('F z :: SYN k) (a :: SYN k) (b :: SYN k) Source Github # 
Instance details

Defined in Proarrow.Tools.SMC.Internal.Additive

caseOf :: forall {k} (a :: SYN k) (b :: SYN k) (c :: SYN k) (d :: Nat) (g :: Ctx k) (r1 :: Ctx k) (r2 :: Ctx k) t1 cont1 t2 cont2 (s :: SYN k) (p :: CAT k). (Distributive k, Promonad p, DistributiveProfunctor p, Sum s a b, KnownObj a, KnownObj b, Binds p d r1 a c t1 cont1, Binds p d r2 b c t2 cont2, Thin (Union r1 r2) r1, Thin (Union r1 r2) r2, Merge (Union r1 r2) g) => TermP p d g s -> (t1 -> cont1) -> (t2 -> cont2) -> TermP p d (Union (Union r1 r2) g) c Source Github #

Case analysis on a coproduct. Each branch receives the contents of its alternative through a pattern (see Patterns), and the variables of the term around it are shared between the branches. This needs the tensor to distribute over the coproduct. The sum may be written with (:||) or embedded by F, as in the result of (-<). For Arr, this needs ArrowChoice and runs only the selected branch.

ifThenElse :: forall {k} (a :: SYN k) (b :: SYN k) (c :: SYN k) (d :: Nat) (g :: Ctx k) (r1 :: Ctx k) (r2 :: Ctx k) t1 cont1 t2 cont2 (s :: SYN k) (p :: CAT k). (Distributive k, Promonad p, DistributiveProfunctor p, Sum s a b, KnownObj a, KnownObj b, Binds p d r1 a c t1 cont1, Binds p d r2 b c t2 cont2, Thin (Union r1 r2) r1, Thin (Union r1 r2) r2, Merge (Union r1 r2) g) => TermP p d g s -> (t1 -> cont1) -> (t2 -> cont2) -> TermP p d (Union (Union r1 r2) g) c Source Github #

caseOf as overloaded if syntax with RebindableSyntax. Import ifThenElse unqualified and write if x then l -> ... else r -> .... The then branch handles the left alternative and the else branch handles the right; each receives its payload.

absurd :: forall {k} {p :: k +-> k} (s :: SYN k) (c :: SYN k) (d :: Nat) (g1 :: Ctx k) (g2 :: Ctx k). (Distributive k, MonoidalProfunctor p, KnownObj s, KnownObj c, Merge g1 g2) => TermP p d g1 s -> TermP p d g2 ('Zero :: SYN k) -> TermP p d (Union g1 g2) c Source Github #

There is no term of Zero, so from one, together with the rest of the context, anything follows.