proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Category.Enriched.Finitary

Description

Profunctors whose hom-sets are finite and numbered: p a b is in bijection with an initial segment of the naturals. This makes limits and colimits computable: an element is an index, so a subset or quotient of a hom-set is a table of indices, which can be reified into a fresh object.

The numbering is a value, as in Proarrow.Category.Instance.FinHask. A type-level size could only be a formula in the sizes it is built from, which rules out constructions whose count depends on how arrows compose, such as the exponential and the subobject classifier.

A DecidableProfunctor is the special case where every size is zero or one; decidableSize and decidableFromIndex build that instance.

This module is only the vocabulary. The category FINITARY j k and everything computed in it live in Proarrow.Category.Enriched.Finitary.Topos. The class and Elt are needed by Powered, Proarrow.Category.Enriched and others that the topos half itself depends on.

Synopsis

Documentation

class Profunctor p => Finitary (p :: j +-> k) where Source Github #

A profunctor with finite, numbered hom-sets. toIndex and fromIndex are inverse for indices below size; fromIndex of anything else is an error, as is toIndex of an element that is not one the instance can produce (which only an unlawfully built value can be).

An instance whose elements are found by searching should define elements and read size off it, rather than let the default call fromIndex once per element and repeat the search each time.

Minimal complete definition

size, toIndex, fromIndex

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

How many elements the hom-set has.

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => p a b -> Natural Source Github #

Where an element sits in elements. Takes its objects like the others do, so that an instance that has to search can bind the search outside the argument lambda and a caller can share it with let toIndexP = toIndex @p @a @b.

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> p a b Source Github #

The element at a position.

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [p a b] Source Github #

All elements of a hom-set, in index order.

Instances

Instances details
Finitary Booleans Source Github #

BOOL is thin, so each hom-set holds at most the one arrow.

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: BOOL) (b :: BOOL). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: BOOL) (b :: BOOL). (Ob a, Ob b) => Booleans a b -> Natural Source Github #

fromIndex :: forall (a :: BOOL) (b :: BOOL). (Ob a, Ob b) => Natural -> Booleans a b Source Github #

elements :: forall (a :: BOOL) (b :: BOOL). (Ob a, Ob b) => [Booleans a b] Source Github #

Finitary FinHask Source Github #

The hom-sets of FINHASK are finite, so its hom-profunctor is finitary. It is numbered in the order of the universe the Finite instance above enumerates, but arithmetically instead of by searching it. A morphism is a table of values indexed by universeF @a. Reading that table as a numeral in base |b|, most significant digit first, gives universe's own order, since universe is traverse (a -> (a,) <$> universe) universe and for lists <*> varies its right operand fastest. So it is the last element of a that varies fastest.

Instance details

Defined in Proarrow.Category.Instance.FinHask

Methods

size :: forall (a :: FINHASK) (b :: FINHASK). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: FINHASK) (b :: FINHASK). (Ob a, Ob b) => FinHask a b -> Natural Source Github #

fromIndex :: forall (a :: FINHASK) (b :: FINHASK). (Ob a, Ob b) => Natural -> FinHask a b Source Github #

elements :: forall (a :: FINHASK) (b :: FINHASK). (Ob a, Ob b) => [FinHask a b] Source Github #

Finitary Unit Source Github #

The one-object category has one arrow.

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: ()) (b :: ()). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: ()) (b :: ()). (Ob a, Ob b) => Unit a b -> Natural Source Github #

fromIndex :: forall (a :: ()) (b :: ()). (Ob a, Ob b) => Natural -> Unit a b Source Github #

elements :: forall (a :: ()) (b :: ()). (Ob a, Ob b) => [Unit a b] Source Github #

(CategoryOf j, CategoryOf k) => Finitary (InitialProfunctor :: k -> j -> Type) Source Github #

The initial profunctor has no elements anywhere.

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => InitialProfunctor a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> InitialProfunctor a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [InitialProfunctor a b] Source Github #

(FiniteCat j, FiniteCat k) => Finitary (Sieve :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Sieve a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> Sieve a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [Sieve a b] Source Github #

(CategoryOf j, CategoryOf k) => Finitary (TerminalProfunctor :: k -> j -> Type) Source Github #

The terminal profunctor has one element everywhere.

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => TerminalProfunctor a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> TerminalProfunctor a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [TerminalProfunctor a b] Source Github #

(HasFiniteCovers t k, FiniteCat j, FiniteCat k) => Finitary (ClosedSieve t :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary.Sheaf

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => ClosedSieve t a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> ClosedSieve t a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [ClosedSieve t a b] Source Github #

(FunctorForRep f, LocallyFinite j) => Finitary (Corep f :: k -> j -> Type) Source Github #

A corepresentable over finite hom-sets is finitary, numbered as the hom-set f '' a ~> b@. (It lives here and not with Corep: Proarrow.Profunctor.Corepresentable is below this module.)

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Corep f a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> Corep f a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [Corep f a b] Source Github #

(HasFiniteCovers t k, Finitary p, FiniteCat j, FiniteCat k) => Finitary (Plus t p :: k -> j -> Type) Source Github #

Numbered by plusElements, as the internal hom is numbered by the natural transformations out of its weight.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Sheaf

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Plus t p a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> Plus t p a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [Plus t p a b] Source Github #

(Finitary p, Finitary q) => Finitary (p :+: q :: k -> j -> Type) Source Github #

The indices of p first, then those of q.

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => (p :+: q) a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> (p :+: q) a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [(p :+: q) a b] Source Github #

(Finitary p, Finitary q, FiniteCat j, FiniteCat k) => Finitary (p :~>: q :: k -> j -> Type) Source Github #

The internal hom of finitary profunctors is finitary: its elements are the natural transformations out of ExpWeight, enumerated. The count is not a formula in the sizes of p and q, since it depends on how the arrows of j and k compose. So size is a value and not a type family.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => (p :~>: q) a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> (p :~>: q) a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [(p :~>: q) a b] Source Github #

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

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => (p :*: q) a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> (p :*: q) a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [(p :*: q) a b] Source Github #

(FiniteCat j, FiniteCat k, Ob a, Ob b) => Finitary (Yo a ('OP b) :: k -> j -> Type) Source Github #

The embedding is finitary when the arrows are: its elements over c/d are an arrow c ~> a paired with an arrow b ~> d, numbered with the first varying slowest. This is the weight of the ends in Proarrow.Category.Enriched.Finitary.Topos, so it shares that module's pairIndex instead of spelling the radix out again.

Instance details

Defined in Proarrow.Profunctor.Instance.Yoneda

Methods

size :: forall (a0 :: k) (b0 :: j). (Ob a0, Ob b0) => Natural Source Github #

toIndex :: forall (a0 :: k) (b0 :: j). (Ob a0, Ob b0) => Yo a ('OP b) a0 b0 -> Natural Source Github #

fromIndex :: forall (a0 :: k) (b0 :: j). (Ob a0, Ob b0) => Natural -> Yo a ('OP b) a0 b0 Source Github #

elements :: forall (a0 :: k) (b0 :: j). (Ob a0, Ob b0) => [Yo a ('OP b) a0 b0] Source Github #

(Finitary w, Finitary s, FiniteCat j) => Finitary (w :.: s :: k -> i -> Type) Source Github #

The composite of finitary profunctors over a finite middle category is finitary. An element at a/c is a pair (u, v) over some middle object x, and pairs are identified along the arrows of the middle category: (rmap f u, v) = (u, lmap f v), the coend ∫^x w a x × s x c. The classes are computed by classes and numbered in order, each shown by its first pair.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a :: k) (b :: i). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: i). (Ob a, Ob b) => (w :.: s) a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: i). (Ob a, Ob b) => Natural -> (w :.: s) a b Source Github #

elements :: forall (a :: k) (b :: i). (Ob a, Ob b) => [(w :.: s) a b] Source Github #

(Finitary p, Enumerable j, Enumerable k, KnownTable (Objects j) (Objects k) fs) => Finitary (Reindex r p fs :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Reindex r p fs a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> Reindex r p fs a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [Reindex r p fs a b] Source Github #

(FiniteCat j, FiniteCat k, KnownTables j k lm rm) => Finitary (Tabulated t lm rm :: k -> j -> Type) Source Github #

The numbering is the value. size is a row's length and the rest is the identity, except for the range check. An index that is the value has nowhere else to fail. Stored unchecked, it would surface much later, as genericIndex running off a row inside dimap.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Tabulated t lm rm a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> Tabulated t lm rm a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [Tabulated t lm rm a b] Source Github #

(Finitary v, Finitary p, FiniteCat i, FiniteCat k) => Finitary (Ran ('OP v) p :: k -> j -> Type) Source Github #

The right Kan extension of finitary profunctors is finitary. It is the right Kan lift in the opposite categories, Ran (OP v) p a b ≅ Rift (OP (Op v)) (Op p) (OP b) (OP a), and is numbered as that is.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Ran ('OP v) p a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> Ran ('OP v) p a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [Ran ('OP v) p a b] Source Github #

(Finitary w, Finitary p, FiniteCat i, FiniteCat j) => Finitary (Rift ('OP w) p :: k -> j -> Type) Source Github #

The right Kan lift of finitary profunctors is finitary: its elements are the natural transformations out of RiftWeight, enumerated, as for the internal hom.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Rift ('OP w) p a b -> Natural Source Github #

fromIndex :: forall (a :: k) (b :: j). (Ob a, Ob b) => Natural -> Rift ('OP w) p a b Source Github #

elements :: forall (a :: k) (b :: j). (Ob a, Ob b) => [Rift ('OP w) p a b] Source Github #

(Finitary w, LocallyFinite j, Ob a, Ob b) => Finitary (RiftWeight w a b :: k2 -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a0 :: k2) (b0 :: j). (Ob a0, Ob b0) => Natural Source Github #

toIndex :: forall (a0 :: k2) (b0 :: j). (Ob a0, Ob b0) => RiftWeight w a b a0 b0 -> Natural Source Github #

fromIndex :: forall (a0 :: k2) (b0 :: j). (Ob a0, Ob b0) => Natural -> RiftWeight w a b a0 b0 Source Github #

elements :: forall (a0 :: k2) (b0 :: j). (Ob a0, Ob b0) => [RiftWeight w a b a0 b0] Source Github #

Finitary (LTE :: ORDINAL n -> ORDINAL n -> Type) Source Github #

The ordinals are thin too, so the same three lines serve. So a chain can be used as a site: a cover there can have a leg that is itself covered, which no coverage on a two-object category can arrange.

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: ORDINAL n) (b :: ORDINAL n). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: ORDINAL n) (b :: ORDINAL n). (Ob a, Ob b) => LTE a b -> Natural Source Github #

fromIndex :: forall (a :: ORDINAL n) (b :: ORDINAL n). (Ob a, Ob b) => Natural -> LTE a b Source Github #

elements :: forall (a :: ORDINAL n) (b :: ORDINAL n). (Ob a, Ob b) => [LTE a b] Source Github #

Finitary p => Finitary (Op p :: OPPOSITE j -> OPPOSITE k -> Type) Source Github #

The opposite of a finitary profunctor is finitary, at the same sizes read the other way round. Taking p = Hom k this makes OPPOSITE k a FiniteCat whenever k is one, so everything computed for a finite site is available on the opposite category too. (This instance lives here rather than with Op because Proarrow.Category.Instance.Opposite sits below this module in the import graph.)

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: OPPOSITE j) (b :: OPPOSITE k). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: OPPOSITE j) (b :: OPPOSITE k). (Ob a, Ob b) => Op p a b -> Natural Source Github #

fromIndex :: forall (a :: OPPOSITE j) (b :: OPPOSITE k). (Ob a, Ob b) => Natural -> Op p a b Source Github #

elements :: forall (a :: OPPOSITE j) (b :: OPPOSITE k). (Ob a, Ob b) => [Op p a b] Source Github #

(InternalIn ik FINSET, SNatI (NumObs ik)) => Finitary (Internal :: INTERNAL ik -> INTERNAL ik -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Internal

Methods

size :: forall (a :: INTERNAL ik) (b :: INTERNAL ik). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: INTERNAL ik) (b :: INTERNAL ik). (Ob a, Ob b) => Internal a b -> Natural Source Github #

fromIndex :: forall (a :: INTERNAL ik) (b :: INTERNAL ik). (Ob a, Ob b) => Natural -> Internal a b Source Github #

elements :: forall (a :: INTERNAL ik) (b :: INTERNAL ik). (Ob a, Ob b) => [Internal a b] Source Github #

(FiniteCat j, FiniteCat k, forall (p :: j +-> k). ob p => SubFinitary p) => Finitary (Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) :: SUBCAT ob -> SUBCAT ob -> Type) Source Github #

FINITARY j k is locally finite: its own hom-profunctor is finitary, by natTransformations, so the numbering is the skeleton of each hom-set and the Finitary laws apply to it. (It is not a FiniteCat: there are unboundedly many finitary profunctors.)

The same holds for any full subcategory whose predicate implies Finitary, such as the sheaves of Proarrow.Category.Enriched.Finitary.Sheaf. The premise goes through SubFinitary because a bare forall p. ob p => Finitary p cannot be discharged for a conjunction such as Finitary :&&: Sheaf t: GHC will not solve the head from a superclass that is not smaller.

Instance details

Defined in Proarrow.Category.Enriched.Finitary.Topos

Methods

size :: forall (a :: SUBCAT ob) (b :: SUBCAT ob). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: SUBCAT ob) (b :: SUBCAT ob). (Ob a, Ob b) => Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) a b -> Natural Source Github #

fromIndex :: forall (a :: SUBCAT ob) (b :: SUBCAT ob). (Ob a, Ob b) => Natural -> Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) a b Source Github #

elements :: forall (a :: SUBCAT ob) (b :: SUBCAT ob). (Ob a, Ob b) => [Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) a b] Source Github #

(Finitary p, Finitary q) => Finitary (p :**: q :: (k1, k2) -> (j1, j2) -> Type) Source Github #

The product of two finitary profunctors on the product of their kinds, numbered as :*: is.

Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

size :: forall (a :: (k1, k2)) (b :: (j1, j2)). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: (k1, k2)) (b :: (j1, j2)). (Ob a, Ob b) => (p :**: q) a b -> Natural Source Github #

fromIndex :: forall (a :: (k1, k2)) (b :: (j1, j2)). (Ob a, Ob b) => Natural -> (p :**: q) a b Source Github #

elements :: forall (a :: (k1, k2)) (b :: (j1, j2)). (Ob a, Ob b) => [(p :**: q) a b] Source Github #

(Finitary (Hom j), Finitary (Hom k), Finitary p) => Finitary (Collage :: COLLAGE p -> COLLAGE p -> Type) Source Github #

The collage of a finitary profunctor between finite categories is a finite category: a hom-set is a base hom-set, an element set of p for a cross-arrow, or empty going back.

This is the cheapest source of a finite category that is not a poset: elements of p between one pair of objects are parallel arrows.

Instance details

Defined in Proarrow.Category.Instance.Collage

Methods

size :: forall (a :: COLLAGE p) (b :: COLLAGE p). (Ob a, Ob b) => Natural Source Github #

toIndex :: forall (a :: COLLAGE p) (b :: COLLAGE p). (Ob a, Ob b) => Collage a b -> Natural Source Github #

fromIndex :: forall (a :: COLLAGE p) (b :: COLLAGE p). (Ob a, Ob b) => Natural -> Collage a b Source Github #

elements :: forall (a :: COLLAGE p) (b :: COLLAGE p). (Ob a, Ob b) => [Collage a b] Source Github #

indices :: Natural -> [Natural] Source Github #

[0 .. n-1], which n being a Natural rules out writing directly.

sizes :: forall {j} {k} (p :: j +-> k). (Finitary p, Enumerable j, Enumerable k) => [Natural] Source Github #

A finitary profunctor's hom-set sizes, one per pair of objects, the outer index running over k and the inner over j. Cheap enough to display an object by: a presheaf on the graph schema, say, shows as [2,4,2,4].

objIndex :: forall {k} (a :: k). (Enumerable k, Ob a) => Natural Source Github #

The position of an object in its kind's object list.

foreachOb :: Enumerable k => (forall (a :: k). Ob a => [r]) -> [r] Source Github #

Everything an enumeration of a kind's objects can do at each of them, concatenated.

Thin profunctors

decidableSize :: forall {j} {k} (p :: j +-> k) (a :: k) (b :: j). (DecidableProfunctor p, Ob a, Ob b) => Natural Source Github #

A decidable profunctor has one element where it holds and none where it does not. These cannot be default method bodies: size and fromIndex do not mention their objects except in a constraint, so GHC cannot tie a default body's objects to the instance's.

decidableFromIndex :: forall {j} {k} p (a :: k) (b :: j). (DecidableProfunctor p, Ob a, Ob b) => Natural -> p a b Source Github #

Hom-sets as finite sets

newtype Elt (p :: j +-> k) (a :: k) (b :: j) Source Github #

An element of a hom-set of p, viewed as an element of a finite set: every instance the universe package asks for is supplied by the numbering, with toIndex standing in for equality and ordering. So a finitary profunctor is a profunctor enriched in FINHASK.

Constructors

Elt 

Fields

Instances

Instances details
Finitary p => Show (Elt p a b) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

showsPrec :: Int -> Elt p a b -> ShowS Github #

show :: Elt p a b -> String Github #

showList :: [Elt p a b] -> ShowS Github #

Finitary p => Eq (Elt p a b) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

(==) :: Elt p a b -> Elt p a b -> Bool Github #

(/=) :: Elt p a b -> Elt p a b -> Bool Github #

Finitary p => Ord (Elt p a b) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

compare :: Elt p a b -> Elt p a b -> Ordering Github #

(<) :: Elt p a b -> Elt p a b -> Bool Github #

(<=) :: Elt p a b -> Elt p a b -> Bool Github #

(>) :: Elt p a b -> Elt p a b -> Bool Github #

(>=) :: Elt p a b -> Elt p a b -> Bool Github #

max :: Elt p a b -> Elt p a b -> Elt p a b Github #

min :: Elt p a b -> Elt p a b -> Elt p a b Github #

(Finitary p, Ob a, Ob b) => Finite (Elt p a b) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

universeF :: [Elt p a b] Github #

cardinality :: Tagged (Elt p a b) Natural Github #

(Finitary p, Ob a, Ob b) => Universe (Elt p a b) Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary

Methods

universe :: [Elt p a b] Github #

class (CategoryOf k, Finitary (Hom k)) => LocallyFinite k Source Github #

A category whose hom-sets are finite: the Finitary counterpart of Decidable, and one half of FiniteCat.

Instances

Instances details
(CategoryOf k, Finitary (Hom k)) => LocallyFinite k Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary

factorThrough :: forall {k} (x :: k) (y :: k) (a :: k). (LocallyFinite k, Ob x, Ob y, Ob a) => (x ~> a) -> (y ~> a) -> Maybe (x ~> y) Source Github #

How an arrow factors through another into the same object: factorThrough g f is an h with g = f . h, if there is one. Only the hom-set x ~> y is searched, so only the hom-sets need to be finite. An element is in the image of f iff it factors through f.

factorsThrough :: forall {k} (x :: k) (y :: k) (a :: k). (LocallyFinite k, Ob x, Ob y, Ob a) => (x ~> a) -> (y ~> a) -> Bool Source Github #

Whether an arrow factors through another, which is factorThrough with the witness dropped. generatedSieve is the caller: a cover's sieve is the arrows that factor through one of its legs.

class (Enumerable k, Finitary (Hom k)) => FiniteCat k Source Github #

A finite category: finitely many objects, and finitely many arrows between them. The first is Enumerable, the second does not follow from it, and the enumeration below needs both.

Instances

Instances details
(Enumerable k, Finitary (Hom k)) => FiniteCat k Source Github # 
Instance details

Defined in Proarrow.Category.Enriched.Finitary

finiteSize :: forall {j} {k} (p :: j +-> k) (a :: k) (b :: j). Finite (p a b) => Natural Source Github #

A profunctor between categories with finite hom-sets is finitary iff it is enriched in finite sets. These build a Finitary instance from Finite hom-sets, the counterparts of decidableSize and decidableFromIndex one level up.

finiteToIndex and finiteFromIndex search universeF, which is fine for small hom-sets. For large ones compute the index arithmetically, as FinHask does.

finiteToIndex :: forall {j} {k} p (a :: k) (b :: j). (Finite (p a b), Eq (p a b)) => p a b -> Natural Source Github #

finiteFromIndex :: forall {j} {k} p (a :: k) (b :: j). Finite (p a b) => Natural -> p a b Source Github #

Products and coproducts

pairIndex :: Natural -> Natural -> Natural -> Natural Source Github #

A pair of indices as one index, row-major: the first factor varies slowest. Shared by the two instances that number a pair of independent choices (the product profunctor and the Yoneda embedding), because ExpWeight nests one inside the other, so they have to agree.

unpairIndex :: Natural -> Natural -> (Natural, Natural) Source Github #

The inverse, given the size of the second factor.