{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE MultiParamTypeClasses #-}

{-| Module  : FiniteCategories
Description : The __'Parallel'__ category contains two parallel arrows.
Copyright   : Guillaume Sabbagh 2022
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 Math.FiniteCategories.Parallel 
(
    ParallelOb(..),
    ParallelAr(..),
    Parallel(..)
)
where
    import          Math.FiniteCategory
    import          Math.IO.PrettyPrint
    
    import          Data.WeakSet.Safe
    import          Data.Simplifiable
    
    import          GHC.Generics
    
    -- | Objects of the __'Parallel'__ category.

    data ParallelOb = ParallelA | ParallelB deriving (ParallelOb -> ParallelOb -> Bool
(ParallelOb -> ParallelOb -> Bool)
-> (ParallelOb -> ParallelOb -> Bool) -> Eq ParallelOb
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ParallelOb -> ParallelOb -> Bool
== :: ParallelOb -> ParallelOb -> Bool
$c/= :: ParallelOb -> ParallelOb -> Bool
/= :: 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
$cshowsPrec :: Int -> ParallelOb -> ShowS
showsPrec :: Int -> ParallelOb -> ShowS
$cshow :: ParallelOb -> String
show :: ParallelOb -> String
$cshowList :: [ParallelOb] -> ShowS
showList :: [ParallelOb] -> ShowS
Show, (forall x. ParallelOb -> Rep ParallelOb x)
-> (forall x. Rep ParallelOb x -> ParallelOb) -> Generic ParallelOb
forall x. Rep ParallelOb x -> ParallelOb
forall x. ParallelOb -> Rep ParallelOb x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ParallelOb -> Rep ParallelOb x
from :: forall x. ParallelOb -> Rep ParallelOb x
$cto :: forall x. Rep ParallelOb x -> ParallelOb
to :: forall x. Rep ParallelOb x -> ParallelOb
Generic, Int -> Int -> String -> ParallelOb -> String
Int -> ParallelOb -> String
(Int -> ParallelOb -> String)
-> (Int -> Int -> String -> ParallelOb -> String)
-> (Int -> ParallelOb -> String)
-> PrettyPrint ParallelOb
forall a.
(Int -> a -> String)
-> (Int -> Int -> String -> a -> String)
-> (Int -> a -> String)
-> PrettyPrint a
$cpprint :: Int -> ParallelOb -> String
pprint :: Int -> ParallelOb -> String
$cpprintWithIndentations :: Int -> Int -> String -> ParallelOb -> String
pprintWithIndentations :: Int -> Int -> String -> ParallelOb -> String
$cpprintIndent :: Int -> ParallelOb -> String
pprintIndent :: Int -> ParallelOb -> String
PrettyPrint, ParallelOb -> ParallelOb
(ParallelOb -> ParallelOb) -> Simplifiable ParallelOb
forall a. (a -> a) -> Simplifiable a
$csimplify :: ParallelOb -> ParallelOb
simplify :: ParallelOb -> ParallelOb
Simplifiable)
    
    -- | Morphisms of the __'Parallel'__ category.

    data ParallelAr = ParallelIdA | ParallelIdB | ParallelF | ParallelG deriving (ParallelAr -> ParallelAr -> Bool
(ParallelAr -> ParallelAr -> Bool)
-> (ParallelAr -> ParallelAr -> Bool) -> Eq ParallelAr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ParallelAr -> ParallelAr -> Bool
== :: ParallelAr -> ParallelAr -> Bool
$c/= :: ParallelAr -> ParallelAr -> Bool
/= :: 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
$cshowsPrec :: Int -> ParallelAr -> ShowS
showsPrec :: Int -> ParallelAr -> ShowS
$cshow :: ParallelAr -> String
show :: ParallelAr -> String
$cshowList :: [ParallelAr] -> ShowS
showList :: [ParallelAr] -> ShowS
Show, (forall x. ParallelAr -> Rep ParallelAr x)
-> (forall x. Rep ParallelAr x -> ParallelAr) -> Generic ParallelAr
forall x. Rep ParallelAr x -> ParallelAr
forall x. ParallelAr -> Rep ParallelAr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ParallelAr -> Rep ParallelAr x
from :: forall x. ParallelAr -> Rep ParallelAr x
$cto :: forall x. Rep ParallelAr x -> ParallelAr
to :: forall x. Rep ParallelAr x -> ParallelAr
Generic, Int -> Int -> String -> ParallelAr -> String
Int -> ParallelAr -> String
(Int -> ParallelAr -> String)
-> (Int -> Int -> String -> ParallelAr -> String)
-> (Int -> ParallelAr -> String)
-> PrettyPrint ParallelAr
forall a.
(Int -> a -> String)
-> (Int -> Int -> String -> a -> String)
-> (Int -> a -> String)
-> PrettyPrint a
$cpprint :: Int -> ParallelAr -> String
pprint :: Int -> ParallelAr -> String
$cpprintWithIndentations :: Int -> Int -> String -> ParallelAr -> String
pprintWithIndentations :: Int -> Int -> String -> ParallelAr -> String
$cpprintIndent :: Int -> ParallelAr -> String
pprintIndent :: Int -> ParallelAr -> String
PrettyPrint, ParallelAr -> ParallelAr
(ParallelAr -> ParallelAr) -> Simplifiable ParallelAr
forall a. (a -> a) -> Simplifiable a
$csimplify :: ParallelAr -> ParallelAr
simplify :: ParallelAr -> ParallelAr
Simplifiable)
    
    -- | 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
$c== :: Parallel -> Parallel -> Bool
== :: Parallel -> Parallel -> Bool
$c/= :: Parallel -> Parallel -> Bool
/= :: 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
$cshowsPrec :: Int -> Parallel -> ShowS
showsPrec :: Int -> Parallel -> ShowS
$cshow :: Parallel -> String
show :: Parallel -> String
$cshowList :: [Parallel] -> ShowS
showList :: [Parallel] -> ShowS
Show, (forall x. Parallel -> Rep Parallel x)
-> (forall x. Rep Parallel x -> Parallel) -> Generic Parallel
forall x. Rep Parallel x -> Parallel
forall x. Parallel -> Rep Parallel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Parallel -> Rep Parallel x
from :: forall x. Parallel -> Rep Parallel x
$cto :: forall x. Rep Parallel x -> Parallel
to :: forall x. Rep Parallel x -> Parallel
Generic, Int -> Int -> String -> Parallel -> String
Int -> Parallel -> String
(Int -> Parallel -> String)
-> (Int -> Int -> String -> Parallel -> String)
-> (Int -> Parallel -> String)
-> PrettyPrint Parallel
forall a.
(Int -> a -> String)
-> (Int -> Int -> String -> a -> String)
-> (Int -> a -> String)
-> PrettyPrint a
$cpprint :: Int -> Parallel -> String
pprint :: Int -> Parallel -> String
$cpprintWithIndentations :: Int -> Int -> String -> Parallel -> String
pprintWithIndentations :: Int -> Int -> String -> Parallel -> String
$cpprintIndent :: Int -> Parallel -> String
pprintIndent :: Int -> Parallel -> String
PrettyPrint, Parallel -> Parallel
(Parallel -> Parallel) -> Simplifiable Parallel
forall a. (a -> a) -> Simplifiable a
$csimplify :: Parallel -> Parallel
simplify :: Parallel -> Parallel
Simplifiable)
    
    instance Morphism ParallelAr ParallelOb where
        source :: ParallelAr -> ParallelOb
source ParallelAr
ParallelIdA = ParallelOb
ParallelA
        source ParallelAr
ParallelIdB = ParallelOb
ParallelB
        source ParallelAr
_ = ParallelOb
ParallelA
        target :: ParallelAr -> ParallelOb
target ParallelAr
ParallelIdA = ParallelOb
ParallelA
        target ParallelAr
ParallelIdB = ParallelOb
ParallelB
        target ParallelAr
_ = ParallelOb
ParallelB
        @ :: ParallelAr -> ParallelAr -> ParallelAr
(@) ParallelAr
ParallelIdA ParallelAr
ParallelIdA = ParallelAr
ParallelIdA
        (@) ParallelAr
ParallelF ParallelAr
ParallelIdA = ParallelAr
ParallelF
        (@) ParallelAr
ParallelG ParallelAr
ParallelIdA =  ParallelAr
ParallelG
        (@) ParallelAr
ParallelIdB ParallelAr
ParallelIdB =  ParallelAr
ParallelIdB
        (@) ParallelAr
ParallelIdB ParallelAr
ParallelF =  ParallelAr
ParallelF
        (@) ParallelAr
ParallelIdB ParallelAr
ParallelG =  ParallelAr
ParallelG
        (@) ParallelAr
_ ParallelAr
_ = String -> ParallelAr
forall a. HasCallStack => String -> a
error String
"Incompatible composition of Parallel morphisms."
        
    instance Category Parallel ParallelAr ParallelOb where
        identity :: Morphism ParallelAr ParallelOb =>
Parallel -> ParallelOb -> ParallelAr
identity Parallel
_ ParallelOb
ParallelA = ParallelAr
ParallelIdA
        identity Parallel
_ ParallelOb
ParallelB = ParallelAr
ParallelIdB
        ar :: Morphism ParallelAr ParallelOb =>
Parallel -> ParallelOb -> ParallelOb -> Set ParallelAr
ar Parallel
_ ParallelOb
ParallelA ParallelOb
ParallelA = [ParallelAr] -> Set ParallelAr
forall a. [a] -> Set a
set [ParallelAr
ParallelIdA]
        ar Parallel
_ ParallelOb
ParallelA ParallelOb
ParallelB = [ParallelAr] -> Set ParallelAr
forall a. [a] -> Set a
set [ParallelAr
ParallelF,ParallelAr
ParallelG]
        ar Parallel
_ ParallelOb
ParallelB ParallelOb
ParallelB = [ParallelAr] -> Set ParallelAr
forall a. [a] -> Set a
set [ParallelAr
ParallelIdB]
        ar Parallel
_ ParallelOb
_ ParallelOb
_ = [ParallelAr] -> Set ParallelAr
forall a. [a] -> Set a
set []
        
    
    instance FiniteCategory Parallel ParallelAr ParallelOb where
        ob :: Parallel -> Set ParallelOb
ob Parallel
_ = [ParallelOb] -> Set ParallelOb
forall a. [a] -> Set a
set [ParallelOb
ParallelA,ParallelOb
ParallelB]