| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Category.Internal
Description
Internal categories: ik `InternalIn` k is a category internal to k, given by an object of
objects , an object of arrows C0 ik, and source/target/identity/composition
structure maps.C1 ik
Internal to finite sets these are the finite categories, and each direction needs a different
presentation of finite sets. A FiniteCat counts its arrows only at the value level, so it is
internal to FINHASK. Going back,
Enumerable wants the object list as a type, which only the
skeleton FINSET supplies, so INTERNAL is built from an
internal category in FINSET.
Synopsis
- class InternalIn (ik :: k) k1 where
- newtype ObIx k = ObIx Natural
- data ArrIx k = ArrIx {}
- data CompIx k = CompIx (ArrIx k) (ArrIx k)
- obCount :: Enumerable k => Natural
- withObIx :: Enumerable k => Natural -> (forall (a :: k). Ob a => Proxy a -> r) -> r
- homSize :: FiniteCat k => Natural -> Natural -> Natural
- type NumObs (ik :: k) = UN 'FS (C0 ik :: FINSET)
- type NumArrs (ik :: k) = UN 'FS (C1 ik :: FINSET)
- data INTERNAL (ik :: k) = IN (ORDINAL (NumObs ik))
- data Internal (a :: INTERNAL ik) (b :: INTERNAL ik) where
- tableOf :: forall (a :: FINSET) (b :: FINSET). FinSet a b -> [Natural]
- compTable :: forall {k} (ik :: k). InternalIn ik FINSET => [(Natural, Natural, Natural)]
- obNum :: forall {k} {ik :: k} (a :: INTERNAL ik). (Enumerable (INTERNAL ik), Ob a) => Natural
- internalIsFinite :: forall {k} (ik :: k) r. (InternalIn ik FINSET, SNatI (NumObs ik)) => (FiniteCat (INTERNAL ik) => r) -> r
Documentation
class InternalIn (ik :: k) k1 where Source Github #
An internal category in a category k.
Methods
source :: (C1 ik :: k1) ~> (C0 ik :: k1) Source Github #
target :: (C1 ik :: k1) ~> (C0 ik :: k1) Source Github #
identity :: (C0 ik :: k1) ~> (C1 ik :: k1) Source Github #
compose :: Cosink '[C1 ik :: k1, C1 ik :: k1, C1 ik :: k1] Source Github #
Instances
| FiniteCat k => InternalIn (k :: Kind) FINHASK Source Github # | Every finite category is a category internal to At
| ||||||||
Defined in Proarrow.Category.Internal Associated Types
| |||||||||
| InternalIn BOOL FINSET Source Github # |
| ||||||||
Defined in Proarrow.Category.Internal Associated Types
Methods source :: (C1 BOOL :: FINSET) ~> (C0 BOOL :: FINSET) Source Github # target :: (C1 BOOL :: FINSET) ~> (C0 BOOL :: FINSET) Source Github # identity :: (C0 BOOL :: FINSET) ~> (C1 BOOL :: FINSET) Source Github # compose :: Cosink '[C1 BOOL :: FINSET, C1 BOOL :: FINSET, C1 BOOL :: FINSET] Source Github # | |||||||||
Finite categories are the ones internal to FINHASK
newtype ObIx k Source Github #
An object of k as an inhabitant of a finite Haskell type: its index in
.Objects k
Instances
| Show (ObIx k) Source Github # | |
| Eq (ObIx k) Source Github # | |
| Ord (ObIx k) Source Github # | |
| Enumerable k => Finite (ObIx k) Source Github # | |
| Enumerable k => Universe (ObIx k) Source Github # | |
Defined in Proarrow.Category.Internal | |
An arrow of k as an inhabitant of a finite Haskell type: the indices of its source and target
objects, and its own position in that hom-set.
Instances
| Show (ArrIx k) Source Github # | |
| Eq (ArrIx k) Source Github # | |
| Ord (ArrIx k) Source Github # | |
Defined in Proarrow.Category.Internal | |
| FiniteCat k => Finite (ArrIx k) Source Github # | |
| FiniteCat k => Universe (ArrIx k) Source Github # | |
Defined in Proarrow.Category.Internal | |
A composable pair, and the apex of compose: the pullback of source along target. The
arrows are given outer first, so that the legs of compose come out in the order that instance
wants them: the first leg composed after the second.
Instances
| Show (CompIx k) Source Github # | |
| Eq (CompIx k) Source Github # | |
| Ord (CompIx k) Source Github # | |
Defined in Proarrow.Category.Internal | |
| FiniteCat k => Finite (CompIx k) Source Github # | |
| FiniteCat k => Universe (CompIx k) Source Github # | |
Defined in Proarrow.Category.Internal | |
obCount :: Enumerable k => Natural Source Github #
How many objects k has, by walking its object list.
homSize :: FiniteCat k => Natural -> Natural -> Natural Source Github #
The size of a hom-set, named by the indices of its endpoints.
The converse: an internal category in FINSET is a finite category
type NumObs (ik :: k) = UN 'FS (C0 ik :: FINSET) Source Github #
How many objects and how many arrows an internal category in FINSET has. These are types.
That is what FINSET has over FINHASK, and the converse
needs it, because Enumerable asks for its object list at the type level.
data INTERNAL (ik :: k) Source Github #
The category an internal category in FINSET presents, as a kind: its objects are the elements
of , numbered by C0 ikORDINAL.
Instances
data Internal (a :: INTERNAL ik) (b :: INTERNAL ik) where Source Github #
An arrow of the presented category: an element of . That its C1 iksource and target are
the objects claimed is a runtime invariant, as the table invariants of FinSet are.
Constructors
| Internal :: forall {k} (ik :: k) (a :: INTERNAL ik) (b :: INTERNAL ik). (Ob a, Ob b) => Natural -> Internal a b |
Instances
tableOf :: forall (a :: FINSET) (b :: FINSET). FinSet a b -> [Natural] Source Github #
A structure map as a list of indices into its codomain.
compTable :: forall {k} (ik :: k). InternalIn ik FINSET => [(Natural, Natural, Natural)] Source Github #
The composition table: for each composable pair, the outer arrow, the inner arrow, and their
composite, as indices into .C1 ik
obNum :: forall {k} {ik :: k} (a :: INTERNAL ik). (Enumerable (INTERNAL ik), Ob a) => Natural Source Github #
Which element of an object names.C0 ik
internalIsFinite :: forall {k} (ik :: k) r. (InternalIn ik FINSET, SNatI (NumObs ik)) => (FiniteCat (INTERNAL ik) => r) -> r Source Github #
The converse, as a statement: an internal category in FINSET presents a FiniteCat.
At BOOL the presented category has the hom-sets of BOOL back: one arrow each way except from
TRU to FLS, where there is none.
>>>import Proarrow.Category.Instance.Ordinal (ORDINAL (..))>>>:{[ size @(Hom (INTERNAL BOOL)) @(IN OZ) @(IN OZ) , size @(Hom (INTERNAL BOOL)) @(IN OZ) @(IN (OS OZ)) , size @(Hom (INTERNAL BOOL)) @(IN (OS OZ)) @(IN OZ) , size @(Hom (INTERNAL BOOL)) @(IN (OS OZ)) @(IN (OS OZ)) ] :: [Natural] :} [1,1,0,1]
>>>let f = fromIndex @(Hom (INTERNAL BOOL)) @(IN OZ) @(IN (OS OZ)) 0>>>toIndex @(Hom (INTERNAL BOOL)) @(IN OZ) @(IN (OS OZ)) (id @_ @(IN (OS OZ)) . f)0