{-# LANGUAGE MultiParamTypeClasses #-}

{-| Module  : FiniteCategories
Description : The square category contains 4 generating arrows forming a square.
Copyright   : Guillaume Sabbagh 2021
License     : GPL-3
Maintainer  : guillaumesabbagh@protonmail.com
Stability   : experimental
Portability : portable

The square category contains 4 generating arrows forming a square.
-}

module UsualCategories.Square
(
    SquareOb(..),
    SquareAr(..),
    Square(..)
)
where
    import          FiniteCategory.FiniteCategory
    import          IO.PrettyPrint
    
    -- | Object of the Square category.

    data SquareOb = A | B | C | D deriving (SquareOb -> SquareOb -> Bool
(SquareOb -> SquareOb -> Bool)
-> (SquareOb -> SquareOb -> Bool) -> Eq SquareOb
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SquareOb -> SquareOb -> Bool
$c/= :: SquareOb -> SquareOb -> Bool
== :: SquareOb -> SquareOb -> Bool
$c== :: SquareOb -> SquareOb -> Bool
Eq, Int -> SquareOb -> ShowS
[SquareOb] -> ShowS
SquareOb -> String
(Int -> SquareOb -> ShowS)
-> (SquareOb -> String) -> ([SquareOb] -> ShowS) -> Show SquareOb
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SquareOb] -> ShowS
$cshowList :: [SquareOb] -> ShowS
show :: SquareOb -> String
$cshow :: SquareOb -> String
showsPrec :: Int -> SquareOb -> ShowS
$cshowsPrec :: Int -> SquareOb -> ShowS
Show)
    
    -- | Morphism of the Square category.

    data SquareAr = IdA | IdB | IdC | IdD | F | G | H | I | FH | GI deriving (SquareAr -> SquareAr -> Bool
(SquareAr -> SquareAr -> Bool)
-> (SquareAr -> SquareAr -> Bool) -> Eq SquareAr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SquareAr -> SquareAr -> Bool
$c/= :: SquareAr -> SquareAr -> Bool
== :: SquareAr -> SquareAr -> Bool
$c== :: SquareAr -> SquareAr -> Bool
Eq, Int -> SquareAr -> ShowS
[SquareAr] -> ShowS
SquareAr -> String
(Int -> SquareAr -> ShowS)
-> (SquareAr -> String) -> ([SquareAr] -> ShowS) -> Show SquareAr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SquareAr] -> ShowS
$cshowList :: [SquareAr] -> ShowS
show :: SquareAr -> String
$cshow :: SquareAr -> String
showsPrec :: Int -> SquareAr -> ShowS
$cshowsPrec :: Int -> SquareAr -> ShowS
Show)
    
    -- | The Square category.

    data Square = Square deriving (Square -> Square -> Bool
(Square -> Square -> Bool)
-> (Square -> Square -> Bool) -> Eq Square
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Square -> Square -> Bool
$c/= :: Square -> Square -> Bool
== :: Square -> Square -> Bool
$c== :: Square -> Square -> Bool
Eq, Int -> Square -> ShowS
[Square] -> ShowS
Square -> String
(Int -> Square -> ShowS)
-> (Square -> String) -> ([Square] -> ShowS) -> Show Square
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Square] -> ShowS
$cshowList :: [Square] -> ShowS
show :: Square -> String
$cshow :: Square -> String
showsPrec :: Int -> Square -> ShowS
$cshowsPrec :: Int -> Square -> ShowS
Show)
    
    instance Morphism SquareAr SquareOb where
        source :: SquareAr -> SquareOb
source SquareAr
IdA = SquareOb
A
        source SquareAr
IdB = SquareOb
B
        source SquareAr
IdC = SquareOb
C
        source SquareAr
IdD = SquareOb
D
        source SquareAr
F = SquareOb
A
        source SquareAr
G = SquareOb
A
        source SquareAr
H = SquareOb
B
        source SquareAr
I = SquareOb
C
        source SquareAr
FH = SquareOb
A
        source SquareAr
GI = SquareOb
A
        target :: SquareAr -> SquareOb
target SquareAr
IdA = SquareOb
A
        target SquareAr
IdB = SquareOb
B
        target SquareAr
IdC = SquareOb
C
        target SquareAr
IdD = SquareOb
D
        target SquareAr
F = SquareOb
B
        target SquareAr
G = SquareOb
C
        target SquareAr
H = SquareOb
D
        target SquareAr
I = SquareOb
D
        target SquareAr
FH = SquareOb
D
        target SquareAr
GI = SquareOb
D
        @ :: SquareAr -> SquareAr -> SquareAr
(@) SquareAr
IdA SquareAr
IdA = SquareAr
IdA
        (@) SquareAr
F SquareAr
IdA = SquareAr
F
        (@) SquareAr
G SquareAr
IdA = SquareAr
G
        (@) SquareAr
FH SquareAr
IdA = SquareAr
FH
        (@) SquareAr
GI SquareAr
IdA = SquareAr
GI
        (@) SquareAr
IdB SquareAr
IdB = SquareAr
IdB
        (@) SquareAr
H SquareAr
IdB = SquareAr
H
        (@) SquareAr
IdC SquareAr
IdC = SquareAr
IdC
        (@) SquareAr
I SquareAr
IdC = SquareAr
I
        (@) SquareAr
IdD SquareAr
IdD = SquareAr
IdD
        (@) SquareAr
IdB SquareAr
F = SquareAr
F
        (@) SquareAr
H SquareAr
F = SquareAr
FH
        (@) SquareAr
IdC SquareAr
G = SquareAr
G
        (@) SquareAr
I SquareAr
G = SquareAr
GI
        (@) SquareAr
IdD SquareAr
H = SquareAr
H
        (@) SquareAr
IdD SquareAr
I = SquareAr
I
        (@) SquareAr
IdD SquareAr
FH = SquareAr
FH
        (@) SquareAr
IdD SquareAr
GI = SquareAr
GI
        
    instance FiniteCategory Square SquareAr SquareOb where
        ob :: Square -> [SquareOb]
ob = [SquareOb] -> Square -> [SquareOb]
forall a b. a -> b -> a
const [SquareOb
A,SquareOb
B,SquareOb
C,SquareOb
D]
        identity :: Morphism SquareAr SquareOb => Square -> SquareOb -> SquareAr
identity Square
_ SquareOb
A = SquareAr
IdA
        identity Square
_ SquareOb
B = SquareAr
IdB
        identity Square
_ SquareOb
C = SquareAr
IdC
        identity Square
_ SquareOb
D = SquareAr
IdD
        ar :: Morphism SquareAr SquareOb =>
Square -> SquareOb -> SquareOb -> [SquareAr]
ar Square
_ SquareOb
A SquareOb
A = [SquareAr
IdA]
        ar Square
_ SquareOb
A SquareOb
B = [SquareAr
F]
        ar Square
_ SquareOb
A SquareOb
C = [SquareAr
G]
        ar Square
_ SquareOb
A SquareOb
D = [SquareAr
FH,SquareAr
GI]
        ar Square
_ SquareOb
B SquareOb
B = [SquareAr
IdB]
        ar Square
_ SquareOb
B SquareOb
D = [SquareAr
H]
        ar Square
_ SquareOb
C SquareOb
C = [SquareAr
IdC]
        ar Square
_ SquareOb
C SquareOb
D = [SquareAr
I]
        ar Square
_ SquareOb
D SquareOb
D = [SquareAr
IdD]
        ar Square
_ SquareOb
_ SquareOb
_ = []
        
    instance GeneratedFiniteCategory Square SquareAr SquareOb where
        genAr :: Morphism SquareAr SquareOb =>
Square -> SquareOb -> SquareOb -> [SquareAr]
genAr = Square -> SquareOb -> SquareOb -> [SquareAr]
forall c m o.
(GeneratedFiniteCategory c m o, Morphism m o) =>
c -> o -> o -> [m]
defaultGenAr
        decompose :: Morphism SquareAr SquareOb => Square -> SquareAr -> [SquareAr]
decompose = Square -> SquareAr -> [SquareAr]
forall c m o.
(GeneratedFiniteCategory c m o, Morphism m o) =>
c -> m -> [m]
defaultDecompose
        
    instance PrettyPrintable SquareOb where
        pprint :: SquareOb -> String
pprint = SquareOb -> String
forall a. Show a => a -> String
show
        
    instance PrettyPrintable SquareAr where
        pprint :: SquareAr -> String
pprint = SquareAr -> String
forall a. Show a => a -> String
show
    
    instance PrettyPrintable Square where
        pprint :: Square -> String
pprint = Square -> String
forall a. Show a => a -> String
show