| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Core
Description
Synopsis
- type (+->) j k = k -> j -> Type
- type CAT k = k +-> k
- type OB k = k -> Constraint
- type Kind = Type
- class Any (a :: k)
- class Promonad ((~>) :: CAT k) => CategoryOf k where
- class (Promonad cat, CategoryOf k, cat ~ ((~>) :: CAT k)) => Category (cat :: CAT k)
- class (CategoryOf j, CategoryOf k) => Profunctor (p :: j +-> k) where
- type (:~>) (p :: k -> k1 -> Type) (q :: k -> k1 -> Type) = forall (a :: k) (b :: k1). p a b -> q a b
- (//) :: forall {k1} {k2} p (a :: k2) (b :: k1) r. Profunctor p => p a b -> ((Ob a, Ob b) => r) -> r
- lmap :: forall {j} {k} p (c :: k) (a :: k) (b :: j). Profunctor p => (c ~> a) -> p a b -> p c b
- rmap :: forall {j} {k} p (b :: j) (d :: j) (a :: k). Profunctor p => (b ~> d) -> p a b -> p a d
- dimapDefault :: forall {k} p (c :: k) (a :: k) (b :: k) (d :: k). Promonad p => p c a -> p b d -> p a b -> p c d
- class Profunctor p => Promonad (p :: k +-> k) where
- arr :: forall {k} p (a :: k) (b :: k). Promonad p => (a ~> b) -> p a b
- type Obj (a :: k) = a ~> a
- obj :: forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
- src :: forall {j} {k} (a :: k) (b :: j) p. Profunctor p => p a b -> Obj a
- tgt :: forall {k1} {k2} (a :: k2) (b :: k1) p. Profunctor p => p a b -> Obj b
- type family UN (w :: j -> k) (wa :: k) :: j
- type Is (w :: j -> k) (a :: k) = a ~ w (UN w a)
Type Infrastructure
Basic Type Definitions
type (+->) j k = k -> j -> Type infixr 0 Source Comments #
The kind j +-> k of profunctors from category j to category k.
Note that this follows mathematical convention,
swapping the order compared to Haskell's contravariant-first ordering.
type OB k = k -> Constraint Source Comments #
Object constraints for kind k.
Universal Constraint
class Any (a :: k) Source Comments #
A constraint that's always satisfied, used as a default when no specific object constraints are needed.
Instances
| Any (a :: k) Source Comments # | |
Defined in Proarrow.Core | |
Category Infrastructure
CategoryOf Class
class Promonad ((~>) :: CAT k) => CategoryOf k Source Comments #
Establishes that k is a category by specifying the morphism type and object constraints.
Associated Types
type (~>) :: CAT k infixr 0 Source Comments #
The type of morphisms in the category.
type Ob (a :: k) Source Comments #
What constraints objects must satisfy.
Instances
| CategoryOf Nat Source Comments # | The category of qubits, to implement ZX calculus from quantum computing. | ||||||||
Defined in Proarrow.Category.Instance.ZX Associated Types
| |||||||||
| CategoryOf BOOL Source Comments # | The category of 2 objects and one arrow between them, a.k.a. the walking arrow. | ||||||||
Defined in Proarrow.Category.Instance.Bool Associated Types
| |||||||||
| CategoryOf KIND Source Comments # | The category of categories and profunctors between them. | ||||||||
Defined in Proarrow.Category.Instance.Cat Associated Types
| |||||||||
| CategoryOf CONSTRAINT Source Comments # | The category of type class constraints. An arrow from constraint a to constraint b | means that a implies b, i.e. if a holds then b holds. | ||||||||
Defined in Proarrow.Category.Instance.Constraint Associated Types
| |||||||||
| CategoryOf COST Source Comments # | Cost category. Categories enriched in the cost category are lawvere metric spaces. | ||||||||
Defined in Proarrow.Category.Instance.Cost Associated Types
| |||||||||
| CategoryOf LINEAR Source Comments # | Category of linear functions. | ||||||||
Defined in Proarrow.Category.Instance.Linear | |||||||||
| CategoryOf POINTED Source Comments # | The category of types with an added point and point-preserving morphisms. | ||||||||
Defined in Proarrow.Category.Instance.PointedHask | |||||||||
| CategoryOf Nat Source Comments # | The (augmented) simplex category is the category of finite ordinals and order preserving maps. | ||||||||
Defined in Proarrow.Category.Instance.Simplex Associated Types
| |||||||||
| CategoryOf VOID Source Comments # | The category with no objects, the initial category. | ||||||||
Defined in Proarrow.Category.Instance.Zero Associated Types
| |||||||||
| CategoryOf () Source Comments # | The category with one object, the terminal category. | ||||||||
Defined in Proarrow.Category.Instance.Unit Associated Types
| |||||||||
| CategoryOf Symbol Source Comments # | |||||||||
Defined in Proarrow.Tools.Laws Associated Types
| |||||||||
| CategoryOf Type Source Comments # | The category of Haskell types (a.k.a | ||||||||
Defined in Proarrow.Core Associated Types
| |||||||||
| CategoryOf (CODISCRETE k) Source Comments # | The codiscrete category has exactly one arrow between every object, every type of kind | ||||||||
Defined in Proarrow.Category.Instance.Discrete Associated Types
| |||||||||
| CategoryOf (DISCRETE k) Source Comments # | The discrete category with only identity arrows, every type of kind | ||||||||
Defined in Proarrow.Category.Instance.Discrete | |||||||||
| CategoryOf (FIN n) Source Comments # | The (thin) category of finite ordinals. An arrow from a to b means that a is less than or equal to b. | ||||||||
Defined in Proarrow.Category.Instance.Fin | |||||||||
| TracedMonoidal k => CategoryOf (INT k) Source Comments # | The Int construction, a.k.a. the geometry of interaction, the free compact closed category on a traced monoidal category. | ||||||||
Defined in Proarrow.Category.Instance.IntConstruction Associated Types
| |||||||||
| Num a => CategoryOf (MatK a) Source Comments # | The category of matrices with entries in a type | ||||||||
Defined in Proarrow.Category.Instance.Mat | |||||||||
| CategoryOf k => CategoryOf (REV k) Source Comments # | The reverse of the category of | ||||||||
Defined in Proarrow.Category.Monoidal.Rev | |||||||||
| CategoryOf k => CategoryOf (OPPOSITE k) Source Comments # | The opposite category of the category of | ||||||||
Defined in Proarrow.Category.Opposite | |||||||||
| CategoryOf k => CategoryOf (COPROD k) Source Comments # | The same category as the category of | ||||||||
Defined in Proarrow.Object.BinaryCoproduct | |||||||||
| CategoryOf k => CategoryOf (PROD k) Source Comments # | The same category as the category of | ||||||||
Defined in Proarrow.Object.BinaryProduct | |||||||||
| CategoryOf k => CategoryOf (LIST k) Source Comments # | The category of lists of arrows. | ||||||||
Defined in Proarrow.Profunctor.List | |||||||||
| Monoidal k => CategoryOf [k] Source Comments # | The strictified monoidal category, making the unitors and associators identities. | ||||||||
Defined in Proarrow.Category.Monoidal.Strictified Associated Types
| |||||||||
| CategoryOf (PROFK j k) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.Prof | |||||||||
| (Applicative f, CategoryOf k) => CategoryOf (AP f k) Source Comments # | |||||||||
Defined in Proarrow.Category.Instance.Ap | |||||||||
| (CategoryOf j, CategoryOf k) => CategoryOf (COPRODUCT j k) Source Comments # | The coproduct of two categories. | ||||||||
Defined in Proarrow.Category.Instance.Coproduct | |||||||||
| Promonad p => CategoryOf (KLEISLI p) Source Comments # | Every promonad makes a category. | ||||||||
Defined in Proarrow.Category.Instance.Kleisli | |||||||||
| CategoryOf (NatK j k) Source Comments # | The category of functors and natural transformations. | ||||||||
Defined in Proarrow.Category.Instance.Nat | |||||||||
| CategoryOf k => CategoryOf (SUBCAT ob) Source Comments # | The subcategory with objects with instances of the given constraint | ||||||||
Defined in Proarrow.Category.Instance.Sub | |||||||||
| (j ~ '(), k ~ '()) => CategoryOf (Unit j k) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.Terminal | |||||||||
| CategoryOf (j +-> k) Source Comments # | The category of profunctors and natural transformations between them. | ||||||||
Defined in Proarrow.Category.Instance.Prof | |||||||||
| Monoid m => CategoryOf (MONOIDK m) Source Comments # | A monoid as a one object category. | ||||||||
Defined in Proarrow.Monoid | |||||||||
| (CategoryOf k1, CategoryOf k2) => CategoryOf (k1, k2) Source Comments # | The product of two categories. | ||||||||
Defined in Proarrow.Category.Instance.Product | |||||||||
| CategoryOf (k1 -> k2 -> k3 -> k4 -> Type) Source Comments # | The category of functors with target category k2 -> k3 -> k4 -> Type. | ||||||||
Defined in Proarrow.Category.Instance.Nat | |||||||||
| CategoryOf (k1 -> k2 -> k3 -> Type) Source Comments # | The category of functors with target category | ||||||||
Defined in Proarrow.Category.Instance.Nat | |||||||||
| CategoryOf (k1 -> Type) Source Comments # | The category of functors with target category Hask. | ||||||||
Defined in Proarrow.Category.Instance.Nat | |||||||||
| (CategoryOf k, Ob i, Ob j) => CategoryOf (PLAINK k i j) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.CategoryAsBi | |||||||||
| CategoryOf k => CategoryOf (MonK k i j) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.MonoidalAsBi | |||||||||
| Profunctor p => CategoryOf (COLLAGE p) Source Comments # | The collage of a profunctor. | ||||||||
Defined in Proarrow.Category.Instance.Collage | |||||||||
| Ok cs p => CategoryOf (FREE cs p) Source Comments # | |||||||||
Defined in Proarrow.Category.Instance.Free | |||||||||
| (Bicategory kk, Ob0 kk k) => CategoryOf (ENDO kk k) Source Comments # | |||||||||
Defined in Proarrow.Category.Monoidal.Endo | |||||||||
| CategoryOf (DiscreteK ob j k) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.Bidiscrete Associated Types
| |||||||||
| CategoryOf (kk j k2) => CategoryOf (COK kk j k2) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.Co | |||||||||
| CategoryOf (kk k2 j) => CategoryOf (OPK kk j k2) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.Op | |||||||||
| (CategoryOf (kk j k2), Bicategory kk) => CategoryOf (Path kk j k2) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.Strictified Associated Types
| |||||||||
| MonoidalAction m k => CategoryOf (STT m k i j) Source Comments # | |||||||||
Defined in Proarrow.Category.Equipment.Stateful | |||||||||
| IsChart m c d => CategoryOf (CHART m c d) Source Comments # | The category of charts. | ||||||||
Defined in Proarrow.Category.Monoidal.Optic | |||||||||
| IsOptic m c d => CategoryOf (OPTIC m c d) Source Comments # | The category of optics. | ||||||||
Defined in Proarrow.Category.Monoidal.Optic | |||||||||
| CategoryOf (kk i j) => CategoryOf (HK kk i j) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.Hom | |||||||||
| CategoryOf (kk i j) => CategoryOf (SUBCAT tag kk i j) Source Comments # | The subcategory with objects with instances of the given constraint `IsOb tag`. | ||||||||
Defined in Proarrow.Category.Bicategory.Sub | |||||||||
| CategoryOf (kk i j) => CategoryOf (WKK kk i j) Source Comments # | |||||||||
Defined in Proarrow.Category.Equipment.BiAsEquipment | |||||||||
| CategoryOf (kk i j) => CategoryOf (QKK kk i j) Source Comments # | |||||||||
Defined in Proarrow.Category.Equipment.Quintet | |||||||||
| (CategoryOf (jj (Fst ik) (Fst jl)), CategoryOf (kk (Snd ik) (Snd jl))) => CategoryOf (PRODK jj kk ik jl) Source Comments # | |||||||||
Defined in Proarrow.Category.Bicategory.Product | |||||||||
Category Class
class (Promonad cat, CategoryOf k, cat ~ ((~>) :: CAT k)) => Category (cat :: CAT k) Source Comments #
A convenience class that bundles together the requirements for a well-formed category.
The automatic instance means you get Category for free once you have CategoryOf and Promonad.
Profunctors
Profunctor Class
class (CategoryOf j, CategoryOf k) => Profunctor (p :: j +-> k) where Source Comments #
The core profunctor abstraction. A profunctor is contravariant in its first argument and covariant in its second argument.
Laws:
Minimal complete definition
Methods
dimap :: forall (c :: k) (a :: k) (b :: j) (d :: j). (c ~> a) -> (b ~> d) -> p a b -> p c d Source Comments #
Map contravariantly over the first argument and covariantly over the second.
(\\) :: forall (a :: k) (b :: j) r. ((Ob a, Ob b) => r) -> p a b -> r infixl 1 Source Comments #
Constraint elimination, extracts object constraints from a profunctor heteromorphism..
Instances
Natural Transformations
type (:~>) (p :: k -> k1 -> Type) (q :: k -> k1 -> Type) = forall (a :: k) (b :: k1). p a b -> q a b infixr 0 Source Comments #
Natural transformation between profunctors.
Profunctor Utilities
(//) :: forall {k1} {k2} p (a :: k2) (b :: k1) r. Profunctor p => p a b -> ((Ob a, Ob b) => r) -> r infixr 0 Source Comments #
Flipped version of (\\).
lmap :: forall {j} {k} p (c :: k) (a :: k) (b :: j). Profunctor p => (c ~> a) -> p a b -> p c b Source Comments #
Left mapping (contravariant mapping over first argument).
rmap :: forall {j} {k} p (b :: j) (d :: j) (a :: k). Profunctor p => (b ~> d) -> p a b -> p a d Source Comments #
Right mapping (covariant mapping over second argument).
Default Implementation
dimapDefault :: forall {k} p (c :: k) (a :: k) (b :: k) (d :: k). Promonad p => p c a -> p b d -> p a b -> p c d Source Comments #
Default implementation of dimap for promonads using composition.
Promonads
Promonad Class
class Profunctor p => Promonad (p :: k +-> k) where Source Comments #
A promonad is a category-like profunctor with identity morphisms and composition.
Laws:
Methods
id :: forall (a :: k). Ob a => p a a Source Comments #
Identity morphisms.
(.) :: forall (b :: k) (c :: k) (a :: k). p b c -> p a b -> p a c infixr 9 Source Comments #
Composition (note the parameter order matches function composition).
Instances
Promonad Utilities
arr :: forall {k} p (a :: k) (b :: k). Promonad p => (a ~> b) -> p a b Source Comments #
Lifts morphisms from the base category into the promonad.
Object Identities
obj :: forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a Source Comments #
The identity morphism for a given object.
Compared to id this makes the kind argument implicit,
allowing to write obj @a instead of id @k @a.
src :: forall {j} {k} (a :: k) (b :: j) p. Profunctor p => p a b -> Obj a Source Comments #
Extract source identity morphism from a profunctor heteromorphism.
tgt :: forall {k1} {k2} (a :: k2) (b :: k1) p. Profunctor p => p a b -> Obj b Source Comments #
Extract target identity morphism from a profunctor heteromorphism.
Type Family Utilities
Kind Unwrapping
type family UN (w :: j -> k) (wa :: k) :: j Source Comments #
A helper type family to unwrap a wrapped kind. This is needed because the field selector functions of newtypes have to be lower case and therefore cannot be used at the type level.
Instances
| type UN 'K ('K k :: KIND) Source Comments # | |
Defined in Proarrow.Category.Instance.Cat | |
| type UN 'CNSTRNT ('CNSTRNT a :: CONSTRAINT) Source Comments # | |
Defined in Proarrow.Category.Instance.Constraint | |
| type UN 'L ('L a :: LINEAR) Source Comments # | |
Defined in Proarrow.Category.Instance.Linear | |
| type UN 'P ('P a :: POINTED) Source Comments # | |
Defined in Proarrow.Category.Instance.PointedHask | |
| type UN ('M :: Nat -> MatK a) ('M n :: MatK a) Source Comments # | |
| type UN ('CD :: j -> CODISCRETE j) ('CD a :: CODISCRETE j) Source Comments # | |
Defined in Proarrow.Category.Instance.Discrete | |
| type UN ('D :: j -> DISCRETE j) ('D a :: DISCRETE j) Source Comments # | |
| type UN ('R :: j -> REV j) ('R a :: REV j) Source Comments # | |
| type UN ('OP :: j -> OPPOSITE j) ('OP k :: OPPOSITE j) Source Comments # | |
| type UN ('COPR :: j -> COPROD j) ('COPR k :: COPROD j) Source Comments # | |
| type UN ('PR :: j -> PROD j) ('PR k :: PROD j) Source Comments # | |
| type UN ('F :: j -> FK j) ('F a :: FK j) Source Comments # | |
| type UN ('A :: j -> AP f j) ('A k :: AP f j) Source Comments # | |
| type UN ('KL :: j -> KLEISLI p) ('KL k :: KLEISLI p) Source Comments # | |
| type UN ('SUB :: j -> SUBCAT ob) ('SUB k :: SUBCAT ob) Source Comments # | |
| type UN ('EMB :: j -> FREE cs p) ('EMB a :: FREE cs p) Source Comments # | |
| type UN ('MK :: j1 -> MonK j1 i j2) ('MK k :: MonK j1 i j2) Source Comments # | |
| type UN ('L :: [k] -> LIST k) ('L as :: LIST k) Source Comments # | |
| type UN ('PK :: (j +-> k) -> PROFK j k) ('PK p :: PROFK j k) Source Comments # | |
| type UN ('NT :: (j -> k) -> NatK j k) ('NT f :: NatK j k) Source Comments # | |
| type UN ('E :: kk k k -> ENDO kk k) ('E p :: ENDO kk k) Source Comments # | |
| type UN ('ST :: (k +-> k) -> STT m k i j) ('ST p :: STT m k i j) Source Comments # | |
| type UN ('CO :: kk j k2 -> COK kk j k2) ('CO k3 :: COK kk j k2) Source Comments # | |
| type UN ('OP :: kk k2 j -> OPK kk j k2) ('OP k3 :: OPK kk j k2) Source Comments # | |
| type UN ('HomK :: kk i j -> HK kk i j) ('HomK k3 :: HK kk i j) Source Comments # | |
| type UN ('SUB :: kk i j -> SUBCAT tag kk i j) ('SUB p :: SUBCAT tag kk i j) Source Comments # | |
| type UN ('WK :: kk i j -> WKK kk i j) ('WK p :: WKK kk i j) Source Comments # | |
| type UN ('QK :: kk i j -> QKK kk i j) ('QK p :: QKK kk i j) Source Comments # | |