{-| Module  : FiniteCategories
Description : Examples of 'FunctorCategory'. Examples of 'Diagram's.
Copyright   : Guillaume Sabbagh 2022
License     : GPL-3
Maintainer  : guillaumesabbagh@protonmail.com
Stability   : experimental
Portability : portable

Examples of 'FunctorCategory'. Examples of 'Diagram's.
-}
module Math.FiniteCategories.FunctorCategory.Examples
(
    exampleFunctorCategory,
    exampleDiagramVToSquare,
    exampleDiagramHatToSquare,
    examplePrecomposedFunctorCategory,
    examplePostcomposedFunctorCategory,
    exampleCgdString,
)
where
    import Data.WeakSet.Safe
    import Data.WeakMap.Safe
    
    import Math.FiniteCategory
    import Math.Categories
    import Math.FiniteCategories
    
    import Math.IO.PrettyPrint
    
    import Data.Text (Text)
    
    -- | The 'FunctorCategory' 3^2.

    exampleFunctorCategory :: FunctorCategory NumberCategory NumberCategoryMorphism NumberCategoryObject NumberCategory NumberCategoryMorphism NumberCategoryObject
    exampleFunctorCategory :: FunctorCategory
  NumberCategory
  NumberCategoryMorphism
  Natural
  NumberCategory
  NumberCategoryMorphism
  Natural
exampleFunctorCategory = NumberCategory
-> NumberCategory
-> FunctorCategory
     NumberCategory
     NumberCategoryMorphism
     Natural
     NumberCategory
     NumberCategoryMorphism
     Natural
forall c1 m1 o1 c2 m2 o2.
c1 -> c2 -> FunctorCategory c1 m1 o1 c2 m2 o2
FunctorCategory (Natural -> NumberCategory
numberCategory Natural
2) (Natural -> NumberCategory
numberCategory Natural
3)
    
    -- | Example of a 'Diagram' from V to Square.

    exampleDiagramVToSquare :: Diagram V VAr VOb Square SquareAr SquareOb
    exampleDiagramVToSquare :: Diagram V VAr VOb Square SquareAr SquareOb
exampleDiagramVToSquare = Diagram V VAr VOb Square SquareAr SquareOb
-> Diagram V VAr VOb Square SquareAr SquareOb
forall c1 m1 o1 c2 m2 o2.
(FiniteCategory c1 m1 o1, Morphism m1 o1, Eq m1, Eq o1,
 Category c2 m2 o2, Morphism m2 o2) =>
Diagram c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2
completeDiagram Diagram{src :: V
src=V
V, tgt :: Square
tgt=Square
Square, omap :: Map VOb SquareOb
omap=AssociationList VOb SquareOb -> Map VOb SquareOb
forall k v. AssociationList k v -> Map k v
weakMap [], mmap :: Map VAr SquareAr
mmap = AssociationList VAr SquareAr -> Map VAr SquareAr
forall k v. AssociationList k v -> Map k v
weakMap [(VAr
VF,SquareAr
SquareH),(VAr
VG,SquareAr
SquareI)]}
    
    -- | Example of a 'Diagram' from Hat to Square.

    exampleDiagramHatToSquare :: Diagram Hat HatAr HatOb Square SquareAr SquareOb
    exampleDiagramHatToSquare :: Diagram Hat HatAr HatOb Square SquareAr SquareOb
exampleDiagramHatToSquare = Diagram Hat HatAr HatOb Square SquareAr SquareOb
-> Diagram Hat HatAr HatOb Square SquareAr SquareOb
forall c1 m1 o1 c2 m2 o2.
(FiniteCategory c1 m1 o1, Morphism m1 o1, Eq m1, Eq o1,
 Category c2 m2 o2, Morphism m2 o2) =>
Diagram c1 m1 o1 c2 m2 o2 -> Diagram c1 m1 o1 c2 m2 o2
completeDiagram Diagram{src :: Hat
src=Hat
Hat, tgt :: Square
tgt=Square
Square, omap :: Map HatOb SquareOb
omap=AssociationList HatOb SquareOb -> Map HatOb SquareOb
forall k v. AssociationList k v -> Map k v
weakMap [], mmap :: Map HatAr SquareAr
mmap = AssociationList HatAr SquareAr -> Map HatAr SquareAr
forall k v. AssociationList k v -> Map k v
weakMap [(HatAr
HatF,SquareAr
SquareF),(HatAr
HatG,SquareAr
SquareG)]}
    
    -- | Example of a 'PrecomposedFunctorCategory'.

    examplePrecomposedFunctorCategory :: PrecomposedFunctorCategory V VAr VOb Square SquareAr SquareOb Square SquareAr SquareOb
    examplePrecomposedFunctorCategory :: PrecomposedFunctorCategory
  V VAr VOb Square SquareAr SquareOb Square SquareAr SquareOb
examplePrecomposedFunctorCategory = Diagram V VAr VOb Square SquareAr SquareOb
-> Square
-> PrecomposedFunctorCategory
     V VAr VOb Square SquareAr SquareOb Square SquareAr SquareOb
forall c1 m1 o1 c2 m2 o2 c3 m3 o3.
Diagram c1 m1 o1 c2 m2 o2
-> c3 -> PrecomposedFunctorCategory c1 m1 o1 c2 m2 o2 c3 m3 o3
PrecomposedFunctorCategory Diagram V VAr VOb Square SquareAr SquareOb
exampleDiagramVToSquare Square
Square
    
    
    -- | Example of a 'PostcomposedFunctorCategory'.

    examplePostcomposedFunctorCategory :: PostcomposedFunctorCategory Square SquareAr SquareOb V VAr VOb Square SquareAr SquareOb
    examplePostcomposedFunctorCategory :: PostcomposedFunctorCategory
  Square SquareAr SquareOb V VAr VOb Square SquareAr SquareOb
examplePostcomposedFunctorCategory = Diagram V VAr VOb Square SquareAr SquareOb
-> Square
-> PostcomposedFunctorCategory
     Square SquareAr SquareOb V VAr VOb Square SquareAr SquareOb
forall c1 m1 o1 c2 m2 o2 c3 m3 o3.
Diagram c2 m2 o2 c3 m3 o3
-> c1 -> PostcomposedFunctorCategory c1 m1 o1 c2 m2 o2 c3 m3 o3
PostcomposedFunctorCategory Diagram V VAr VOb Square SquareAr SquareOb
exampleDiagramVToSquare Square
Square
    
    -- | Example of a 'Diagram' of 'CompositionGraph's constructed by reading a .cgd string.

    exampleCgdString :: Diagram (CompositionGraph Text Text) (CGMorphism Text Text) Text (CompositionGraph Text Text) (CGMorphism Text Text) Text
    Right Diagram
  CG (CGMorphism Text Text) Text CG (CGMorphism Text Text) Text
exampleCgdString = String
-> Either
     (DiagramError
        CG (CGMorphism Text Text) Text CG (CGMorphism Text Text) Text)
     (Diagram
        CG (CGMorphism Text Text) Text CG (CGMorphism Text Text) Text)
readCGDString (String
 -> Either
      (DiagramError
         CG (CGMorphism Text Text) Text CG (CGMorphism Text Text) Text)
      (Diagram
         CG (CGMorphism Text Text) Text CG (CGMorphism Text Text) Text))
-> String
-> Either
     (DiagramError
        CG (CGMorphism Text Text) Text CG (CGMorphism Text Text) Text)
     (Diagram
        CG (CGMorphism Text Text) Text CG (CGMorphism Text Text) Text)
forall a b. (a -> b) -> a -> b
$ String
sourceCGString -> String -> String
forall a. [a] -> [a] -> [a]
++String
targetCGString -> String -> String
forall a. [a] -> [a] -> [a]
++String
"A -f-> B => 1 -a-> 2\n"
        where
            sourceCG :: String
sourceCG = String
"<SRC>\nA -f-> B\n</SRC>\n"
            targetCG :: String
targetCG = String
"<TGT>\n1 -a-> 2\n1 -b-> 3\n</TGT>\n"