| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Data.InternalCategory
Contents
Internal categories
class (IQuiver ob mor, Eq ob) => ICategory ob mor | mor -> ob where Source #
ICategory ob mor defines a category "internal to" Type.
There are two ways to define ICategory: with identity and compose or with foldPath.
Definition by identity, compose
identity, composeThis is how internal categories are usually defined: by giving identity morphisms and composition of two morphisms, satisfying the following laws:
Domain and codomain of identity v:
dom (identity v) == cod (identity v) == v
compose is defined exactly on matching morphisms:
isJust (compose f g) == (cod f == dom g)
Domain and codomain of compose f g:
For all f,g,h such that compose f g == Just h,
dom h == dom f, cod h == cod g
Left and Right Unit:
identity (dom f) compose f == Just f
f compose identity (cod f) == Just f
Associativity:
For all f,g,h,
(compose f g >>= fg -> compose fg h)
==
(compose g h >>= gh -> compose f gh)
Given identity and compose operation, foldPath p
can be defined as the composition morAll of all morphisms in p
(and the identity at source in a case of empty path,) which
is guaranteed to be Just morAll and not Nothing.
Definition by foldPath:
foldPathThis is an alternative definition by giving how to collapse any path on
IQuiver ob mor into mor, satisfying the following laws.
folding doesn't change endpoints:
dom (foldPath p) == dom p
cod (foldPath p) == cod p
folding commutes with concatPath:
For any pp :: Path ob (Path ob mor),
foldPath (concatPath pp) = foldPath (errMapPath id foldPath pp)
Note that from folding doesn't change endpoints law,
errMapPath id foldPath must be a total function.
folding single edge does nothing:
foldPath (singlePath f) = f
Given foldPath, one can defined identity and compose satisfying
the laws above, as
identity :: ob -> mor identity = foldPath . emptyPath compose :: mor -> mor -> Maybe mor compose f g = foldPath $ composePath (singlePath f) (singlePath g)
Instances
| ICategory Void Void Source # | Empty graph |
| ICategory () () Source # | A graph with one vertex and one loop on it |
| Eq a => ICategory a (Codisc a) Source # | |
| Eq a => ICategory a (Disc a) Source # | |
| Eq ob => ICategory ob (Path ob mor) Source # |
|
| (Comonad f, Polynomial f, GEq (Tag f)) => ICategory (Pos f) (Dir f) Source # | |
| (ICategory v e, ICategory w f) => ICategory (Either v w) (Either e f) Source # | Coproduct of category |
| (ICategory v e, ICategory w f) => ICategory (v, w) (e, f) Source # | Product of category |
Path
Bundled Patterns
| pattern Path :: v -> [e] -> v -> Path v e | |
| pattern EmptyPath :: v -> Path v e | |
| pattern NonEmptyPath :: e -> [e] -> Path v e |
Instances
| Show2 Path Source # | |
| Eq ob => ICategory ob (Path ob mor) Source # |
|
| IQuiver v (Path v e) Source # | |
| Show v => Show1 (Path v) Source # | |
| (Show v, Show e) => Show (Path v e) Source # | |
| (Eq e, Eq v) => Eq (Path v e) Source # | |
| (Ord e, Ord v) => Ord (Path v e) Source # | |
Defined in Data.InternalQuiver.Path | |
Reexport
class IQuiver v e | e -> v where Source #
Class for Quiver represented by types of edges and vertices
Instances
| IQuiver Void Void Source # | Empty graph |
| IQuiver () () Source # | A graph with one vertex and one loop on it |
| IQuiver a (Codisc a) Source # | |
| IQuiver a (Disc a) Source # | |
| IQuiver v (Path v e) Source # | |
| (Comonad f, Polynomial f, GEq (Tag f)) => IQuiver (Pos f) (Dir f) Source # | |
| (IQuiver v e, IQuiver w f) => IQuiver (Either v w) (Either e f) Source # | |
| (IQuiver v e, IQuiver w f) => IQuiver (v, w) (e, f) Source # | |