FiniteCategories-0.1.0.0: Finite categories and usual categorical constructions on them.
CopyrightGuillaume Sabbagh 2021
LicenseGPL-3
Maintainerguillaumesabbagh@protonmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

FiniteCategory.FiniteCategory

Description

The goal of this module is to represent small finite categories in order to make usual constructions automatically on them (e.g. (co)limits, (co)completion, etc.) There is a package that deals with categories as a data type (Data.Category) but it does not provide Ar and Ob operators because the package uses the fact that the language itself is a category to represent categories (Hask is (almost) a category, Data.Category benefit from type check at compilation time). The counterpart is that to use Data.Category, you need to create yourself the usual constructions on your category. To construct automatically (co)limits and other constructions, we require that the category can enumerate every morphisms between two objects. We also require that the objects are not types because we want to create objects at runtime (that is why we abandon type check at compilation time for the structure of our categories). Lastly, we require that morphisms can be equated for usual constructions purposes.

For example, see the FinSet category and the Composition Graph.

Synopsis

Morphism typeclass and related functions

class Morphism m o | m -> o where Source #

A morphism can be composed with the (@) operator, it has a source and a target.

The (@) operator should not be confused with the as-pattern. When using the operator, surround the @ symbol with spaces.

Morphism is a multiparametrized type class where m is the type of the morphism and o the type of the objects source and target. Source and target are the same type of objects, we distinguish objects not by their type but instead by their values.

Methods

(@) :: m -> m -> m Source #

The composition g@f should throw an error if source g != target f. This is a consequence of loosing type check at compilation time, we defer the exception handling to execution time.

Composition is associative :

f @ (g @ h) = (f @ g) @ h

source :: m -> o Source #

target :: m -> o Source #

Instances

Instances details
Morphism Zero Zero Source # 
Instance details

Defined in UsualCategories.Zero

Morphism VAr VOb Source # 
Instance details

Defined in UsualCategories.V

Methods

(@) :: VAr -> VAr -> VAr Source #

source :: VAr -> VOb Source #

target :: VAr -> VOb Source #

Morphism TwoAr TwoOb Source # 
Instance details

Defined in UsualCategories.Two

Morphism ThreeAr ThreeOb Source # 
Instance details

Defined in UsualCategories.Three

Morphism SquareAr SquareOb Source # 
Instance details

Defined in UsualCategories.Square

Morphism ParallelAr ParallelOb Source # 
Instance details

Defined in UsualCategories.Parallel

Morphism One One Source # 
Instance details

Defined in UsualCategories.One

Methods

(@) :: One -> One -> One Source #

source :: One -> One Source #

target :: One -> One Source #

Morphism HatAr HatOb Source # 
Instance details

Defined in UsualCategories.Hat

Eq a => Morphism (DiscreteIdentity a) (DiscreteObject a) Source # 
Instance details

Defined in UsualCategories.DiscreteCategory

Ord a => Morphism (FinOrdMap a) (Set a) Source # 
Instance details

Defined in Set.FinOrdSet

Methods

(@) :: FinOrdMap a -> FinOrdMap a -> FinOrdMap a Source #

source :: FinOrdMap a -> Set a Source #

target :: FinOrdMap a -> Set a Source #

Eq a => Morphism (FinMap a) (FinSet a) Source # 
Instance details

Defined in Set.FinSet

Methods

(@) :: FinMap a -> FinMap a -> FinMap a Source #

source :: FinMap a -> FinSet a Source #

target :: FinMap a -> FinSet a Source #

Morphism m o => Morphism (OppositeMorphism m o) o Source # 
Instance details

Defined in OppositeCategory.OppositeCategory

(Eq a, Eq b) => Morphism (CGMorphism a b) a Source # 
Instance details

Defined in CompositionGraph.CompositionGraph

Methods

(@) :: CGMorphism a b -> CGMorphism a b -> CGMorphism a b Source #

source :: CGMorphism a b -> a Source #

target :: CGMorphism a b -> a Source #

(Eq a, Eq b) => Morphism (SCGMorphism a b) a Source # 
Instance details

Defined in CompositionGraph.SafeCompositionGraph

Methods

(@) :: SCGMorphism a b -> SCGMorphism a b -> SCGMorphism a b Source #

source :: SCGMorphism a b -> a Source #

target :: SCGMorphism a b -> a Source #

(Eq c, Eq m, Eq o) => Morphism (FinFunctor c m o) c Source # 
Instance details

Defined in Cat.FinCat

Methods

(@) :: FinFunctor c m o -> FinFunctor c m o -> FinFunctor c m o Source #

source :: FinFunctor c m o -> c Source #

target :: FinFunctor c m o -> c Source #

(Eq c, Eq m, Eq o) => Morphism (PartialFunctor c m o) c Source # 
Instance details

Defined in Cat.PartialFinCat

Methods

(@) :: PartialFunctor c m o -> PartialFunctor c m o -> PartialFunctor c m o Source #

source :: PartialFunctor c m o -> c Source #

target :: PartialFunctor c m o -> c Source #

(Morphism m1 o1, Morphism m2 o2) => Morphism (ProductMorphism m1 o1 m2 o2) (ProductObject o1 o2) Source # 
Instance details

Defined in ProductCategory.ProductCategory

Methods

(@) :: ProductMorphism m1 o1 m2 o2 -> ProductMorphism m1 o1 m2 o2 -> ProductMorphism m1 o1 m2 o2 Source #

source :: ProductMorphism m1 o1 m2 o2 -> ProductObject o1 o2 Source #

target :: ProductMorphism m1 o1 m2 o2 -> ProductObject o1 o2 Source #

(Morphism m1 o1, Morphism m2 o2, Eq o1, Eq o2, Eq m3) => Morphism (CommaMorphism o1 o2 m1 m2 m3) (CommaObject o1 o2 m3) Source # 
Instance details

Defined in CommaCategory.CommaCategory

Methods

(@) :: CommaMorphism o1 o2 m1 m2 m3 -> CommaMorphism o1 o2 m1 m2 m3 -> CommaMorphism o1 o2 m1 m2 m3 Source #

source :: CommaMorphism o1 o2 m1 m2 m3 -> CommaObject o1 o2 m3 Source #

target :: CommaMorphism o1 o2 m1 m2 m3 -> CommaObject o1 o2 m3 Source #

(FiniteCategory c1 m1 o1, Morphism m1 o1, Eq c1, Eq m1, Eq o1, FiniteCategory c2 m2 o2, Morphism m2 o2, Eq c2, Eq m2, Eq o2) => Morphism (NaturalTransformation c1 m1 o1 c2 m2 o2) (Diagram c1 m1 o1 c2 m2 o2) Source # 
Instance details

Defined in FunctorCategory.FunctorCategory

Methods

(@) :: NaturalTransformation c1 m1 o1 c2 m2 o2 -> NaturalTransformation c1 m1 o1 c2 m2 o2 -> NaturalTransformation c1 m1 o1 c2 m2 o2 Source #

source :: NaturalTransformation c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2 Source #

target :: NaturalTransformation c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2 Source #

compose :: Morphism m o => [m] -> m Source #

Returns the composition of the list of morphisms.

For example : compose [f,g,h] = f @ g @ h

FiniteCategory typeclass

class FiniteCategory c m o | c -> m, m -> o where Source #

A category is multiparametrized by the type of its morphisms and the type of its objects.

Minimal complete definition

ob, identity, ar

Methods

ob :: c -> [o] Source #

ob should return a list of unique objects :

List.nub (ob c) = ob c

identity :: Morphism m o => c -> o -> m Source #

identity should return the identity associated to the object o in the category c.

The identity morphism is a morphism such that the two following properties are verified :

f @ identity c (source f) = f
identity c (target g) @ g = g

ar Source #

Arguments

:: Morphism m o 
=> c

The category

-> o

The source of the morphisms

-> o

The target of the morphisms

-> [m]

The list of morphisms in the category c between source and target

ar should return the list of all unique arrows between a source and a target :

List.nub (ar c s t) = ar c s t

Arrows with different source or target should not be equal :

(s1 = s2 && t1 = t2) || List.intersect (ar c s1 t1) (ar c s2 t2) = []

arrows :: (FiniteCategory c m o, Morphism m o) => c -> [m] Source #

arrows returns the list of all unique morphisms of a category.

Instances

Instances details
FiniteCategory Zero Zero Zero Source # 
Instance details

Defined in UsualCategories.Zero

Methods

ob :: Zero -> [Zero] Source #

identity :: Zero -> Zero -> Zero Source #

ar :: Zero -> Zero -> Zero -> [Zero] Source #

arrows :: Zero -> [Zero] Source #

FiniteCategory V VAr VOb Source # 
Instance details

Defined in UsualCategories.V

Methods

ob :: V -> [VOb] Source #

identity :: V -> VOb -> VAr Source #

ar :: V -> VOb -> VOb -> [VAr] Source #

arrows :: V -> [VAr] Source #

FiniteCategory Two TwoAr TwoOb Source # 
Instance details

Defined in UsualCategories.Two

Methods

ob :: Two -> [TwoOb] Source #

identity :: Two -> TwoOb -> TwoAr Source #

ar :: Two -> TwoOb -> TwoOb -> [TwoAr] Source #

arrows :: Two -> [TwoAr] Source #

FiniteCategory Three ThreeAr ThreeOb Source # 
Instance details

Defined in UsualCategories.Three

FiniteCategory Square SquareAr SquareOb Source # 
Instance details

Defined in UsualCategories.Square

FiniteCategory Parallel ParallelAr ParallelOb Source # 
Instance details

Defined in UsualCategories.Parallel

FiniteCategory One One One Source # 
Instance details

Defined in UsualCategories.One

Methods

ob :: One -> [One] Source #

identity :: One -> One -> One Source #

ar :: One -> One -> One -> [One] Source #

arrows :: One -> [One] Source #

FiniteCategory Hat HatAr HatOb Source # 
Instance details

Defined in UsualCategories.Hat

Methods

ob :: Hat -> [HatOb] Source #

identity :: Hat -> HatOb -> HatAr Source #

ar :: Hat -> HatOb -> HatOb -> [HatAr] Source #

arrows :: Hat -> [HatAr] Source #

Eq a => FiniteCategory (DiscreteCategory a) (DiscreteIdentity a) (DiscreteObject a) Source # 
Instance details

Defined in UsualCategories.DiscreteCategory

Ord a => FiniteCategory (FinOrdSet a) (FinOrdMap a) (Set a) Source # 
Instance details

Defined in Set.FinOrdSet

Methods

ob :: FinOrdSet a -> [Set a] Source #

identity :: FinOrdSet a -> Set a -> FinOrdMap a Source #

ar :: FinOrdSet a -> Set a -> Set a -> [FinOrdMap a] Source #

arrows :: FinOrdSet a -> [FinOrdMap a] Source #

Eq a => FiniteCategory (FinSetCat a) (FinMap a) (FinSet a) Source # 
Instance details

Defined in Set.FinSet

Methods

ob :: FinSetCat a -> [FinSet a] Source #

identity :: FinSetCat a -> FinSet a -> FinMap a Source #

ar :: FinSetCat a -> FinSet a -> FinSet a -> [FinMap a] Source #

arrows :: FinSetCat a -> [FinMap a] Source #

(Eq a, Eq b) => FiniteCategory (CompositionGraph a b) (CGMorphism a b) a Source # 
Instance details

Defined in CompositionGraph.CompositionGraph

Methods

ob :: CompositionGraph a b -> [a] Source #

identity :: CompositionGraph a b -> a -> CGMorphism a b Source #

ar :: CompositionGraph a b -> a -> a -> [CGMorphism a b] Source #

arrows :: CompositionGraph a b -> [CGMorphism a b] Source #

(Eq a, Eq b) => FiniteCategory (SafeCompositionGraph a b) (SCGMorphism a b) a Source # 
Instance details

Defined in CompositionGraph.SafeCompositionGraph

(FiniteCategory c m o, Morphism m o, Eq m, Eq o) => FiniteCategory (FullSubcategory c m o) m o Source # 
Instance details

Defined in Subcategories.FullSubcategory

Methods

ob :: FullSubcategory c m o -> [o] Source #

identity :: FullSubcategory c m o -> o -> m Source #

ar :: FullSubcategory c m o -> o -> o -> [m] Source #

arrows :: FullSubcategory c m o -> [m] Source #

(FiniteCategory c m o, Morphism m o, Eq m, Eq o) => FiniteCategory (FreeSubcategory c m o) m o Source # 
Instance details

Defined in Subcategories.FreeSubcategory

Methods

ob :: FreeSubcategory c m o -> [o] Source #

identity :: FreeSubcategory c m o -> o -> m Source #

ar :: FreeSubcategory c m o -> o -> o -> [m] Source #

arrows :: FreeSubcategory c m o -> [m] Source #

(FiniteCategory c m o, Morphism m o) => FiniteCategory (OppositeCategory c m o) (OppositeMorphism m o) o Source # 
Instance details

Defined in OppositeCategory.OppositeCategory

(FiniteCategory c m o, Morphism m o, Eq c, Eq m, Eq o) => FiniteCategory (FinCat c m o) (FinFunctor c m o) c Source # 
Instance details

Defined in Cat.FinCat

Methods

ob :: FinCat c m o -> [c] Source #

identity :: FinCat c m o -> c -> FinFunctor c m o Source #

ar :: FinCat c m o -> c -> c -> [FinFunctor c m o] Source #

arrows :: FinCat c m o -> [FinFunctor c m o] Source #

(FiniteCategory c m o, Morphism m o, Eq c, Eq m, Eq o) => FiniteCategory (PartialFinCat c m o) (PartialFunctor c m o) c Source # 
Instance details

Defined in Cat.PartialFinCat

Methods

ob :: PartialFinCat c m o -> [c] Source #

identity :: PartialFinCat c m o -> c -> PartialFunctor c m o Source #

ar :: PartialFinCat c m o -> c -> c -> [PartialFunctor c m o] Source #

arrows :: PartialFinCat c m o -> [PartialFunctor c m o] Source #

(FiniteCategory c1 m1 o1, Morphism m1 o1, Eq m1, Eq o1, FiniteCategory c2 m2 o2, Morphism m2 o2, Eq m2, Eq o2) => FiniteCategory (Subcategory c1 m1 o1 c2 m2 o2) m2 o2 Source # 
Instance details

Defined in Subcategories.Subcategory

Methods

ob :: Subcategory c1 m1 o1 c2 m2 o2 -> [o2] Source #

identity :: Subcategory c1 m1 o1 c2 m2 o2 -> o2 -> m2 Source #

ar :: Subcategory c1 m1 o1 c2 m2 o2 -> o2 -> o2 -> [m2] Source #

arrows :: Subcategory c1 m1 o1 c2 m2 o2 -> [m2] Source #

(FiniteCategory c1 m1 o1, Morphism m1 o1, FiniteCategory c2 m2 o2, Morphism m2 o2) => FiniteCategory (ProductCategory c1 m1 o1 c2 m2 o2) (ProductMorphism m1 o1 m2 o2) (ProductObject o1 o2) Source # 
Instance details

Defined in ProductCategory.ProductCategory

Methods

ob :: ProductCategory c1 m1 o1 c2 m2 o2 -> [ProductObject o1 o2] Source #

identity :: ProductCategory c1 m1 o1 c2 m2 o2 -> ProductObject o1 o2 -> ProductMorphism m1 o1 m2 o2 Source #

ar :: ProductCategory c1 m1 o1 c2 m2 o2 -> ProductObject o1 o2 -> ProductObject o1 o2 -> [ProductMorphism m1 o1 m2 o2] Source #

arrows :: ProductCategory c1 m1 o1 c2 m2 o2 -> [ProductMorphism m1 o1 m2 o2] Source #

(FiniteCategory c1 m1 o1, Morphism m1 o1, Eq m1, Eq o1, FiniteCategory c2 m2 o2, Morphism m2 o2, Eq m2, Eq o2) => FiniteCategory (FunctorCategory c1 m1 o1 c2 m2 o2) (NaturalTransformation c1 m1 o1 c2 m2 o2) (Diagram c1 m1 o1 c2 m2 o2) Source # 
Instance details

Defined in FunctorCategory.FunctorCategory

Methods

ob :: FunctorCategory c1 m1 o1 c2 m2 o2 -> [Diagram c1 m1 o1 c2 m2 o2] Source #

identity :: FunctorCategory c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2 -> NaturalTransformation c1 m1 o1 c2 m2 o2 Source #

ar :: FunctorCategory c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2 -> [NaturalTransformation c1 m1 o1 c2 m2 o2] Source #

arrows :: FunctorCategory c1 m1 o1 c2 m2 o2 -> [NaturalTransformation c1 m1 o1 c2 m2 o2] Source #

(FiniteCategory c1 m1 o1, Morphism m1 o1, Eq m1, Eq o1, FiniteCategory c2 m2 o2, Morphism m2 o2, Eq m2, Eq o2, FiniteCategory c3 m3 o3, Morphism m3 o3, Eq m3) => FiniteCategory (CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3) (CommaMorphism o1 o2 m1 m2 m3) (CommaObject o1 o2 m3) Source # 
Instance details

Defined in CommaCategory.CommaCategory

Methods

ob :: CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3 -> [CommaObject o1 o2 m3] Source #

identity :: CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3 -> CommaObject o1 o2 m3 -> CommaMorphism o1 o2 m1 m2 m3 Source #

ar :: CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3 -> CommaObject o1 o2 m3 -> CommaObject o1 o2 m3 -> [CommaMorphism o1 o2 m1 m2 m3] Source #

arrows :: CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3 -> [CommaMorphism o1 o2 m1 m2 m3] Source #

FiniteCategory functions

arFrom :: (FiniteCategory c m o, Morphism m o) => c -> o -> [m] Source #

arFrom returns the list of unique morphisms going from a specified source.

arFrom2 :: (FiniteCategory c m o, Morphism m o) => c -> [o] -> [m] Source #

arFrom2 same as arFrom but for multiple sources.

arTo :: (FiniteCategory c m o, Morphism m o) => c -> o -> [m] Source #

arTo returns the list of unique morphisms going to a specified target.

arTo2 :: (FiniteCategory c m o, Morphism m o) => c -> [o] -> [m] Source #

arTo2 same as arTo but for multiple targets.

identities :: (FiniteCategory c m o, Morphism m o) => c -> [m] Source #

identities returns all the identities of a category.

isIdentity :: (FiniteCategory c m o, Morphism m o, Eq m, Eq o) => c -> m -> Bool Source #

Returns wether a morphism is an identity in a category.

isNotIdentity :: (FiniteCategory c m o, Morphism m o, Eq m, Eq o) => c -> m -> Bool Source #

Returns wether a morphism is not an identity.

isTerminal :: (FiniteCategory c m o, Morphism m o) => c -> o -> Bool Source #

Returns wether an object is terminal in the category.

isInitial :: (FiniteCategory c m o, Morphism m o) => c -> o -> Bool Source #

Returns wether an object is initial in the category.

terminalObjects :: (FiniteCategory c m o, Morphism m o) => c -> [o] Source #

Returns the list of terminal objects in a category.

initialObjects :: (FiniteCategory c m o, Morphism m o) => c -> [o] Source #

Returns the list of intial objects in a category.

GeneratedFiniteCategory typeclass and related functions

class FiniteCategory c m o => GeneratedFiniteCategory c m o where Source #

GeneratedFiniteCategory is a FiniteCategory where some morphisms are selected as generators. The full category is generated by the generating arrows, which means that every morphism can be written as a composition of several generators. Some algorithms are simplified because they only need to deal with generators, the rest of the properties are deduced by composition. Every FiniteCategory has at least one set of generators : the set of all of its morphisms.

Minimal complete definition

genAr, decompose

Methods

genAr :: Morphism m o => c -> o -> o -> [m] Source #

Same as ar but only returns the generators. genAr c s t should be included in ar c s t.

decompose :: Morphism m o => c -> m -> [m] Source #

decompose decomposes a morphism into a list of generators (according to composition) :

m = compose (decompose c m)

genArrows :: (GeneratedFiniteCategory c m o, Morphism m o) => c -> [m] Source #

Same as arrows but only returns the generators. genArrows c should be included in arrows c.

Instances

Instances details
GeneratedFiniteCategory Zero Zero Zero Source # 
Instance details

Defined in UsualCategories.Zero

Methods

genAr :: Zero -> Zero -> Zero -> [Zero] Source #

decompose :: Zero -> Zero -> [Zero] Source #

genArrows :: Zero -> [Zero] Source #

GeneratedFiniteCategory V VAr VOb Source # 
Instance details

Defined in UsualCategories.V

Methods

genAr :: V -> VOb -> VOb -> [VAr] Source #

decompose :: V -> VAr -> [VAr] Source #

genArrows :: V -> [VAr] Source #

GeneratedFiniteCategory Two TwoAr TwoOb Source # 
Instance details

Defined in UsualCategories.Two

GeneratedFiniteCategory Three ThreeAr ThreeOb Source # 
Instance details

Defined in UsualCategories.Three

GeneratedFiniteCategory Square SquareAr SquareOb Source # 
Instance details

Defined in UsualCategories.Square

GeneratedFiniteCategory Parallel ParallelAr ParallelOb Source # 
Instance details

Defined in UsualCategories.Parallel

GeneratedFiniteCategory One One One Source # 
Instance details

Defined in UsualCategories.One

Methods

genAr :: One -> One -> One -> [One] Source #

decompose :: One -> One -> [One] Source #

genArrows :: One -> [One] Source #

GeneratedFiniteCategory Hat HatAr HatOb Source # 
Instance details

Defined in UsualCategories.Hat

Eq a => GeneratedFiniteCategory (DiscreteCategory a) (DiscreteIdentity a) (DiscreteObject a) Source # 
Instance details

Defined in UsualCategories.DiscreteCategory

Ord a => GeneratedFiniteCategory (FinOrdSet a) (FinOrdMap a) (Set a) Source # 
Instance details

Defined in Set.FinOrdSet

Methods

genAr :: FinOrdSet a -> Set a -> Set a -> [FinOrdMap a] Source #

decompose :: FinOrdSet a -> FinOrdMap a -> [FinOrdMap a] Source #

genArrows :: FinOrdSet a -> [FinOrdMap a] Source #

Eq a => GeneratedFiniteCategory (FinSetCat a) (FinMap a) (FinSet a) Source # 
Instance details

Defined in Set.FinSet

Methods

genAr :: FinSetCat a -> FinSet a -> FinSet a -> [FinMap a] Source #

decompose :: FinSetCat a -> FinMap a -> [FinMap a] Source #

genArrows :: FinSetCat a -> [FinMap a] Source #

(Eq a, Eq b) => GeneratedFiniteCategory (CompositionGraph a b) (CGMorphism a b) a Source # 
Instance details

Defined in CompositionGraph.CompositionGraph

(Eq a, Eq b) => GeneratedFiniteCategory (SafeCompositionGraph a b) (SCGMorphism a b) a Source # 
Instance details

Defined in CompositionGraph.SafeCompositionGraph

(FiniteCategory c m o, Morphism m o, Eq m, Eq o) => GeneratedFiniteCategory (FullSubcategory c m o) m o Source # 
Instance details

Defined in Subcategories.FullSubcategory

Methods

genAr :: FullSubcategory c m o -> o -> o -> [m] Source #

decompose :: FullSubcategory c m o -> m -> [m] Source #

genArrows :: FullSubcategory c m o -> [m] Source #

(FiniteCategory c m o, Morphism m o, Eq m, Eq o) => GeneratedFiniteCategory (FreeSubcategory c m o) m o Source # 
Instance details

Defined in Subcategories.FreeSubcategory

Methods

genAr :: FreeSubcategory c m o -> o -> o -> [m] Source #

decompose :: FreeSubcategory c m o -> m -> [m] Source #

genArrows :: FreeSubcategory c m o -> [m] Source #

(GeneratedFiniteCategory c m o, Morphism m o) => GeneratedFiniteCategory (OppositeCategory c m o) (OppositeMorphism m o) o Source # 
Instance details

Defined in OppositeCategory.OppositeCategory

(FiniteCategory c m o, Morphism m o, Eq c, Eq m, Eq o) => GeneratedFiniteCategory (FinCat c m o) (FinFunctor c m o) c Source # 
Instance details

Defined in Cat.FinCat

Methods

genAr :: FinCat c m o -> c -> c -> [FinFunctor c m o] Source #

decompose :: FinCat c m o -> FinFunctor c m o -> [FinFunctor c m o] Source #

genArrows :: FinCat c m o -> [FinFunctor c m o] Source #

(FiniteCategory c m o, Morphism m o, Eq c, Eq m, Eq o) => GeneratedFiniteCategory (PartialFinCat c m o) (PartialFunctor c m o) c Source # 
Instance details

Defined in Cat.PartialFinCat

Methods

genAr :: PartialFinCat c m o -> c -> c -> [PartialFunctor c m o] Source #

decompose :: PartialFinCat c m o -> PartialFunctor c m o -> [PartialFunctor c m o] Source #

genArrows :: PartialFinCat c m o -> [PartialFunctor c m o] Source #

(GeneratedFiniteCategory c1 m1 o1, Morphism m1 o1, Eq m1, Eq o1, GeneratedFiniteCategory c2 m2 o2, Morphism m2 o2, Eq m2, Eq o2) => GeneratedFiniteCategory (Subcategory c1 m1 o1 c2 m2 o2) m2 o2 Source # 
Instance details

Defined in Subcategories.Subcategory

Methods

genAr :: Subcategory c1 m1 o1 c2 m2 o2 -> o2 -> o2 -> [m2] Source #

decompose :: Subcategory c1 m1 o1 c2 m2 o2 -> m2 -> [m2] Source #

genArrows :: Subcategory c1 m1 o1 c2 m2 o2 -> [m2] Source #

(GeneratedFiniteCategory c1 m1 o1, Morphism m1 o1, GeneratedFiniteCategory c2 m2 o2, Morphism m2 o2) => GeneratedFiniteCategory (ProductCategory c1 m1 o1 c2 m2 o2) (ProductMorphism m1 o1 m2 o2) (ProductObject o1 o2) Source # 
Instance details

Defined in ProductCategory.ProductCategory

Methods

genAr :: ProductCategory c1 m1 o1 c2 m2 o2 -> ProductObject o1 o2 -> ProductObject o1 o2 -> [ProductMorphism m1 o1 m2 o2] Source #

decompose :: ProductCategory c1 m1 o1 c2 m2 o2 -> ProductMorphism m1 o1 m2 o2 -> [ProductMorphism m1 o1 m2 o2] Source #

genArrows :: ProductCategory c1 m1 o1 c2 m2 o2 -> [ProductMorphism m1 o1 m2 o2] Source #

(FiniteCategory c1 m1 o1, Morphism m1 o1, Eq m1, Eq o1, FiniteCategory c2 m2 o2, Morphism m2 o2, Eq m2, Eq o2) => GeneratedFiniteCategory (FunctorCategory c1 m1 o1 c2 m2 o2) (NaturalTransformation c1 m1 o1 c2 m2 o2) (Diagram c1 m1 o1 c2 m2 o2) Source # 
Instance details

Defined in FunctorCategory.FunctorCategory

Methods

genAr :: FunctorCategory c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2 -> [NaturalTransformation c1 m1 o1 c2 m2 o2] Source #

decompose :: FunctorCategory c1 m1 o1 c2 m2 o2 -> NaturalTransformation c1 m1 o1 c2 m2 o2 -> [NaturalTransformation c1 m1 o1 c2 m2 o2] Source #

genArrows :: FunctorCategory c1 m1 o1 c2 m2 o2 -> [NaturalTransformation c1 m1 o1 c2 m2 o2] Source #

(FiniteCategory c1 m1 o1, Morphism m1 o1, Eq m1, Eq o1, FiniteCategory c2 m2 o2, Morphism m2 o2, Eq m2, Eq o2, FiniteCategory c3 m3 o3, Morphism m3 o3, Eq m3) => GeneratedFiniteCategory (CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3) (CommaMorphism o1 o2 m1 m2 m3) (CommaObject o1 o2 m3) Source # 
Instance details

Defined in CommaCategory.CommaCategory

Methods

genAr :: CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3 -> CommaObject o1 o2 m3 -> CommaObject o1 o2 m3 -> [CommaMorphism o1 o2 m1 m2 m3] Source #

decompose :: CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3 -> CommaMorphism o1 o2 m1 m2 m3 -> [CommaMorphism o1 o2 m1 m2 m3] Source #

genArrows :: CommaCategory c1 m1 o1 c2 m2 o2 c3 m3 o3 -> [CommaMorphism o1 o2 m1 m2 m3] Source #

genArFrom :: (GeneratedFiniteCategory c m o, Morphism m o) => c -> o -> [m] Source #

Same as arFrom but only returns the generators. genArFrom c s should be included in arFrom c s.

genArFrom2 :: (GeneratedFiniteCategory c m o, Morphism m o) => c -> [o] -> [m] Source #

Same as arFrom2 but only returns the generators. genArFrom2 c [s] should be included in arFrom2 c [t].

genArTo :: (GeneratedFiniteCategory c m o, Morphism m o) => c -> o -> [m] Source #

Same as arTo but only returns the generators. genArTo c t should be included in arTo c t.

genArTo2 :: (GeneratedFiniteCategory c m o, Morphism m o) => c -> [o] -> [m] Source #

Same as arTo2 but only returns the generators. genArTo2 c [t] should be included in arTo2 c [t].

defaultGenAr :: (GeneratedFiniteCategory c m o, Morphism m o) => c -> o -> o -> [m] Source #

Every FiniteCategory has at least one set of generators : the set of all of its morphisms.

defaultGenAr is a default method for genAr in order to transform any FiniteCategory into a GeneratedFiniteCategory.

Use defaultGenAr in conjonction with defaultDecompose.

defaultDecompose :: (GeneratedFiniteCategory c m o, Morphism m o) => c -> m -> [m] Source #

Every FiniteCategory has at least one set of generators : the set of all of its morphisms.

defaultDecompose is a default method for decompose in order to transform any FiniteCategory into a GeneratedFiniteCategory.

Use defaultDecompose in conjonction with defaultGenAr.

bruteForceDecompose :: (GeneratedFiniteCategory c m o, Morphism m o, Eq m) => c -> m -> [m] Source #

If genAr is implemented, we can find the decomposition of a morphism by bruteforce search (we compose every arrow until we get the morphism we want).

This method is meant to be used temporarly until a proper decompose method is implemented. (It is very slow.)

isGenerator :: (GeneratedFiniteCategory c m o, Morphism m o, Eq m) => c -> m -> Bool Source #

Returns if a morphism is a generating morphism. It can be overloaded to speed it up (for a morphism f, it computes every generators between the source and the target of f and checks if f is in the list.)

isComposite :: (GeneratedFiniteCategory c m o, Morphism m o, Eq m) => c -> m -> Bool Source #

Opposite of isGenerator, i.e. returns if the morphism is composite.

Check for category correctness

data FiniteCategoryError m o Source #

A data type to represent an incoherence inside a category.

Constructors

CompositionNotAssociative
(h@g)@f /= h@(g@f)

Fields

ObjectsNotUnique

dupObj was found multiple times in ob c.

Fields

MorphismsNotUnique

dupMorph was found multiple times in the category.

Fields

ArrowsNotExhaustive

missingAr is an arrow found by calling ar c but is not in arrows c.

Fields

ArrowBetweenUnknownObjects

f was found in the category but its source s or target t is not in ob c.

Fields

  • f :: m
     
  • s :: o
     
  • t :: o
     
WrongSource

f was found by using ar c s t where s /= source f.

Fields

WrongTarget

f was found by using ar c s t where t /= target f.

Fields

IdentityNotLeftNeutral

idL is not a valid identity : f @ idL /= f.

Fields

IdentityNotRightNeutral

idR is not a valid identity : idR @ f /= f.

Fields

MorphismsShouldNotBeEqual

f == g even though they don'y share the same source or target.

Fields

  • f :: m
     
  • g :: m
     
NotTransitive

f@g is not an element of ar c (source g) (target g).

Fields

  • f :: m
     
  • g :: m
     
GeneratorIsNotAMorphism

f is a generator but not a morphism.

Fields

  • f :: m
     
MorphismDoesntDecomposesIntoGenerators

The morphism f decomposes into decomp where notGen is a non generating morphism.

Fields

WrongDecomposition

compose (decompose c f) /= f.

Fields

Instances

Instances details
(Eq m, Eq o) => Eq (FiniteCategoryError m o) Source # 
Instance details

Defined in FiniteCategory.FiniteCategory

(Show m, Show o) => Show (FiniteCategoryError m o) Source # 
Instance details

Defined in FiniteCategory.FiniteCategory

Methods

showsPrec :: Int -> FiniteCategoryError m o -> ShowS

show :: FiniteCategoryError m o -> String

showList :: [FiniteCategoryError m o] -> ShowS

(Show m, Show o) => PrettyPrintable (FiniteCategoryError m o) Source # 
Instance details

Defined in FiniteCategory.FiniteCategory

checkFiniteCategoryProperties :: (FiniteCategory c m o, Morphism m o, Eq m, Eq o) => c -> Maybe (FiniteCategoryError m o) Source #

Checks every properties listed above for a category.

If an error is found in the category, just a FiniteCategoryError is returned. Otherwise, nothing is returned.