proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Category.Monoidal.Cartesian

Description

Cartesian monoidal categories (Cartesian: tensor = product, with CopyDiscard as superclass by Fox's theorem), cartesian closed ones (CCC) and bicartesian closed ones (BiCCC, which implies Distributive): the meeting point of the monoidal and the product worlds, which never import each other. Lives above Proarrow.Category.Monoidal.CopyDiscard rather than with the products, because the superclass points that way.

Synopsis

Documentation

class (a ** b) ~ (a && b) => TensorIsProduct (a :: k) (b :: k) Source Github #

Instances

Instances details
(a ** b) ~ (a && b) => TensorIsProduct (a :: k) (b :: k) Source Github # 
Instance details

Defined in Proarrow.Category.Monoidal.Cartesian

class (HasProducts k, SymMonoidal k, Semicartesian k, CopyDiscard k, forall (a :: k) (b :: k). TensorIsProduct a b) => Cartesian k Source Github #

A cartesian monoidal category: the tensor is the product and the unit the terminal object. By Fox's theorem this is the same as a CopyDiscard category whose copy and discard are natural, so CopyDiscard is a superclass. Every cartesian category supplies its diagonals as comonoids, and anything asking only for copying and discarding (prisms, for instance) accepts a cartesian category directly. The law relating the two is copy = id &&& id and discard = terminate.

Instances

Instances details
(HasProducts k, SymMonoidal k, Semicartesian k, CopyDiscard k, forall (a :: k) (b :: k). TensorIsProduct a b) => Cartesian k Source Github # 
Instance details

Defined in Proarrow.Category.Monoidal.Cartesian

tensorToProduct :: forall {k} (a :: k) (b :: k). (HasBinaryProducts k, TensorIsProduct a b, Ob a, Ob b) => (a ** b) ~> (a && b) Source Github #

In a cartesian category the tensor is the product (TensorIsProduct), but GHC only applies that equation at the top of a type, never under another type family such as (||), and using the quantified form of it directly sends the solver in circles. These two identities take the equation as an ordinary given (discharged at the call site from the quantified superclass of Cartesian), so it can be applied where a product-typed leg meets tensor-typed plumbing.

productToTensor :: forall {k} (a :: k) (b :: k). (HasBinaryProducts k, TensorIsProduct a b, Ob a, Ob b) => (a && b) ~> (a ** b) Source Github #

unparRepCartesian :: forall {j} {k} (p :: j +-> k) (a :: j) (b :: j) (a' :: k) (b' :: k). (Representable p, Cartesian k, Cartesian j, TensorIsProduct a b, TensorIsProduct a' b', Ob a, Ob b) => ((p % a) ~> a') -> ((p % b) ~> b') -> (p % (a ** b)) ~> (a' ** b') Source Github #

class (Cartesian k, Closed k) => CCC k Source Github #

Instances

Instances details
(Cartesian k, Closed k) => CCC k Source Github # 
Instance details

Defined in Proarrow.Category.Monoidal.Cartesian

curryProd :: forall {k} (a :: k) (b :: k) (c :: k). (CCC k, TensorIsProduct a b, Ob a, Ob b) => ((a && b) ~> c) -> a ~> (b ~~> c) Source Github #

Currying with the product, obtained from curry using the cartesian tensor/product equality. It satisfies the currying bijection in the laws of Closed. Keep INLINE [0] on a delegating instance method too, to preserve delayed inlining.

applyProd :: forall {k} (a :: k) (b :: k). (CCC k, TensorIsProduct (a ~~> b) a, Ob a, Ob b) => ((a ~~> b) && a) ~> b Source Github #

Evaluation with the product, obtained from apply using the cartesian tensor/product equality. Together with curryProd it satisfies the currying bijection in the laws of Closed.

class (CCC k, Distributive k) => BiCCC k Source Github #

Bicartesian closed: cartesian closed with coproducts. Every such category is distributive (a && is a left adjoint, so it preserves coproducts), and the class says so, so that Distributive never has to be asked for separately.

Instances

Instances details
(CCC k, Distributive k) => BiCCC k Source Github # 
Instance details

Defined in Proarrow.Category.Monoidal.Cartesian

distLProd :: forall {k} (a :: k) (b :: k) (c :: k). (BiCCC k, Ob a, Ob b, Ob c) => (a && (b || c)) ~> ((a && b) || (a && c)) Source Github #

Distributivity of the product over coproducts, derived from closedness: in any BiCCC the functor a && is a left adjoint and so preserves coproducts.

distRProd :: forall {k} (a :: k) (b :: k) (c :: k). (BiCCC k, Ob a, Ob b, Ob c) => ((a || b) && c) ~> ((a && c) || (b && c)) Source Github #

ap :: forall {j} {k} (y :: j) (a :: k) (x :: j) p. (Closed j, Cartesian k, MonoidalProfunctor p, Ob y) => p a (x ~~> y) -> p a x -> p a y Source Github #

prodToTensor :: forall {k} {cs :: [Kind -> Constraint]} {p :: CAT k} (a :: FREE cs p) (b :: FREE cs p). (Elems '[Cartesian, HasTerminalObject, HasBinaryProducts, Monoidal] cs, Ob a, Ob b) => (a *! b) ~> (a **! b) Source Github #

The formal tensor = product isomorphisms of a free category with Cartesian in its list.

tensorToProd :: forall {k} {cs :: [Kind -> Constraint]} {p :: CAT k} (a :: FREE cs p) (b :: FREE cs p). (Elems '[Cartesian, HasTerminalObject, HasBinaryProducts, Monoidal] cs, Ob a, Ob b) => (a **! b) ~> (a *! b) Source Github #

termToUnit :: forall {k} {cs :: [Kind -> Constraint]} {p :: CAT k}. Elems '[Cartesian, HasTerminalObject, HasBinaryProducts, Monoidal] cs => (TermF :: FREE cs p) ~> (UnitF :: FREE cs p) Source Github #

unitToTerm :: forall {k} {cs :: [Kind -> Constraint]} {p :: CAT k}. Elems '[Cartesian, HasTerminalObject, HasBinaryProducts, Monoidal] cs => (UnitF :: FREE cs p) ~> (TermF :: FREE cs p) Source Github #

Orphan instances

(Representable p, Cartesian j, Cartesian k) => MonoidalProfunctor (RepCostar p :: j -> k -> Type) Source Github #

Every functor between cartesian categories is oplax monoidal, f (a && b) ~> f a && f b by the projections and f Unit ~> Unit by terminality. On the RepCostar of its representable profunctor this is OplaxMonoidal.

Instance details

Methods

one :: RepCostar p (Unit :: j) (Unit :: k) Source Github #

(**) :: forall (x1 :: j) (x2 :: k) (y1 :: j) (y2 :: k). RepCostar p x1 x2 -> RepCostar p y1 y2 -> RepCostar p (x1 ** y1) (x2 ** y2) Source Github #

(Cartesian k, Traversable p, Traversable q) => Traversable (p :*: q :: k -> k -> Type) Source Github # 
Instance details

Methods

traverse :: forall (p0 :: k +-> k). StrongDistributiveProfunctor p0 => ((p :*: q) :.: p0) :~> (p0 :.: (p :*: q)) Source Github #

Closed (PROD Type) Source Github # 
Instance details

Associated Types

type (a :: PROD Type) ~~> (b :: PROD Type) 
Instance details

Defined in Proarrow.Category.Monoidal.Cartesian

type (a :: PROD Type) ~~> (b :: PROD Type) = 'PR (UN ('PR :: Type -> PROD Type) a ~~> UN ('PR :: Type -> PROD Type) b)

Methods

withObExp :: forall (a :: PROD Type) (b :: PROD Type) r. (Ob a, Ob b) => (Ob (a ~~> b) => r) -> r Source Github #

curry :: forall (a :: PROD Type) (b :: PROD Type) (c :: PROD Type). (Ob a, Ob b) => ((a ** b) ~> c) -> a ~> (b ~~> c) Source Github #

apply :: forall (a :: PROD Type) (b :: PROD Type). (Ob a, Ob b) => ((a ~~> b) ** a) ~> b Source Github #

(^^^) :: forall (a :: PROD Type) (b :: PROD Type) (x :: PROD Type) (y :: PROD Type). (b ~> y) -> (x ~> a) -> (a ~~> b) ~> (x ~~> y) Source Github #

HasProducts k => CopyDiscard (PROD k) Source Github #

A category with products, viewed through PROD as a monoidal category, is cartesian.

Instance details

Methods

copy :: forall (a :: PROD k). Ob a => a ~> (a ** a) Source Github #

discard :: forall (a :: PROD k). Ob a => a ~> (Unit :: PROD k) Source Github #

BiCCC k => Distributive (PROD k) Source Github # 
Instance details

Methods

distL :: forall (a :: PROD k) (b :: PROD k) (c :: PROD k). (Ob a, Ob b, Ob c) => (a ** (b || c)) ~> ((a ** b) || (a ** c)) Source Github #

distR :: forall (a :: PROD k) (b :: PROD k) (c :: PROD k). (Ob a, Ob b, Ob c) => ((a || b) ** c) ~> ((a ** c) || (b ** c)) Source Github #

absorbL :: forall (a :: PROD k). Ob a => (a ** (InitialObject :: PROD k)) ~> (InitialObject :: PROD k) Source Github #

absorbR :: forall (a :: PROD k). Ob a => ((InitialObject :: PROD k) ** a) ~> (InitialObject :: PROD k) Source Github #

(HasProducts k, Ob a) => CocommutativeComonoid ('PR a :: PROD k) Source Github # 
Instance details

(HasProducts k, Ob a) => Comonoid ('PR a :: PROD k) Source Github #

In a category with products every object is a comonoid via the diagonal and the terminal map. With this comonoid structure PROD is CopyDiscard and Cartesian.

Instance details

Methods

counit :: 'PR a ~> (Unit :: PROD k) Source Github #

comult :: 'PR a ~> ('PR a ** 'PR a) Source Github #