{-# LANGUAGE MultiParamTypeClasses #-}

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

The parallel category contains two objects `A` and `B` and two morphisms @`F` : `A` -> `B`@ and @`G` : `A` -> `B`@.
-}

module UsualCategories.Parallel 
(
    ParallelOb(..),
    ParallelAr(..),
    Parallel(..)
)
where
    import          FiniteCategory.FiniteCategory
    import          IO.PrettyPrint
    
    -- | Object of the parallel category.

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

    data ParallelAr = IdA | IdB | F | G deriving (ParallelAr -> ParallelAr -> Bool
(ParallelAr -> ParallelAr -> Bool)
-> (ParallelAr -> ParallelAr -> Bool) -> Eq ParallelAr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParallelAr -> ParallelAr -> Bool
$c/= :: ParallelAr -> ParallelAr -> Bool
== :: ParallelAr -> ParallelAr -> Bool
$c== :: ParallelAr -> ParallelAr -> Bool
Eq, Int -> ParallelAr -> ShowS
[ParallelAr] -> ShowS
ParallelAr -> String
(Int -> ParallelAr -> ShowS)
-> (ParallelAr -> String)
-> ([ParallelAr] -> ShowS)
-> Show ParallelAr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParallelAr] -> ShowS
$cshowList :: [ParallelAr] -> ShowS
show :: ParallelAr -> String
$cshow :: ParallelAr -> String
showsPrec :: Int -> ParallelAr -> ShowS
$cshowsPrec :: Int -> ParallelAr -> ShowS
Show)
    
    -- | The parallel category.

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