{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Math.FiniteCategories.Square
(
SquareOb(..),
SquareAr(..),
Square(..)
)
where
import Math.FiniteCategory
import Math.IO.PrettyPrint
import Data.WeakSet.Safe
import Data.Simplifiable
import GHC.Generics
data SquareOb = SquareA | SquareB | SquareC | SquareD deriving (SquareOb -> SquareOb -> Bool
(SquareOb -> SquareOb -> Bool)
-> (SquareOb -> SquareOb -> Bool) -> Eq SquareOb
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SquareOb -> SquareOb -> Bool
== :: SquareOb -> SquareOb -> Bool
$c/= :: SquareOb -> SquareOb -> Bool
/= :: 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
$cshowsPrec :: Int -> SquareOb -> ShowS
showsPrec :: Int -> SquareOb -> ShowS
$cshow :: SquareOb -> String
show :: SquareOb -> String
$cshowList :: [SquareOb] -> ShowS
showList :: [SquareOb] -> ShowS
Show, (forall x. SquareOb -> Rep SquareOb x)
-> (forall x. Rep SquareOb x -> SquareOb) -> Generic SquareOb
forall x. Rep SquareOb x -> SquareOb
forall x. SquareOb -> Rep SquareOb x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SquareOb -> Rep SquareOb x
from :: forall x. SquareOb -> Rep SquareOb x
$cto :: forall x. Rep SquareOb x -> SquareOb
to :: forall x. Rep SquareOb x -> SquareOb
Generic, Int -> Int -> String -> SquareOb -> String
Int -> SquareOb -> String
(Int -> SquareOb -> String)
-> (Int -> Int -> String -> SquareOb -> String)
-> (Int -> SquareOb -> String)
-> PrettyPrint SquareOb
forall a.
(Int -> a -> String)
-> (Int -> Int -> String -> a -> String)
-> (Int -> a -> String)
-> PrettyPrint a
$cpprint :: Int -> SquareOb -> String
pprint :: Int -> SquareOb -> String
$cpprintWithIndentations :: Int -> Int -> String -> SquareOb -> String
pprintWithIndentations :: Int -> Int -> String -> SquareOb -> String
$cpprintIndent :: Int -> SquareOb -> String
pprintIndent :: Int -> SquareOb -> String
PrettyPrint, SquareOb -> SquareOb
(SquareOb -> SquareOb) -> Simplifiable SquareOb
forall a. (a -> a) -> Simplifiable a
$csimplify :: SquareOb -> SquareOb
simplify :: SquareOb -> SquareOb
Simplifiable)
data SquareAr = SquareIdA | SquareIdB | SquareIdC | SquareIdD | SquareF | SquareG | SquareH | SquareI | SquareFH | SquareGI deriving (SquareAr -> SquareAr -> Bool
(SquareAr -> SquareAr -> Bool)
-> (SquareAr -> SquareAr -> Bool) -> Eq SquareAr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SquareAr -> SquareAr -> Bool
== :: SquareAr -> SquareAr -> Bool
$c/= :: SquareAr -> SquareAr -> Bool
/= :: 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
$cshowsPrec :: Int -> SquareAr -> ShowS
showsPrec :: Int -> SquareAr -> ShowS
$cshow :: SquareAr -> String
show :: SquareAr -> String
$cshowList :: [SquareAr] -> ShowS
showList :: [SquareAr] -> ShowS
Show, (forall x. SquareAr -> Rep SquareAr x)
-> (forall x. Rep SquareAr x -> SquareAr) -> Generic SquareAr
forall x. Rep SquareAr x -> SquareAr
forall x. SquareAr -> Rep SquareAr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SquareAr -> Rep SquareAr x
from :: forall x. SquareAr -> Rep SquareAr x
$cto :: forall x. Rep SquareAr x -> SquareAr
to :: forall x. Rep SquareAr x -> SquareAr
Generic, Int -> Int -> String -> SquareAr -> String
Int -> SquareAr -> String
(Int -> SquareAr -> String)
-> (Int -> Int -> String -> SquareAr -> String)
-> (Int -> SquareAr -> String)
-> PrettyPrint SquareAr
forall a.
(Int -> a -> String)
-> (Int -> Int -> String -> a -> String)
-> (Int -> a -> String)
-> PrettyPrint a
$cpprint :: Int -> SquareAr -> String
pprint :: Int -> SquareAr -> String
$cpprintWithIndentations :: Int -> Int -> String -> SquareAr -> String
pprintWithIndentations :: Int -> Int -> String -> SquareAr -> String
$cpprintIndent :: Int -> SquareAr -> String
pprintIndent :: Int -> SquareAr -> String
PrettyPrint, SquareAr -> SquareAr
(SquareAr -> SquareAr) -> Simplifiable SquareAr
forall a. (a -> a) -> Simplifiable a
$csimplify :: SquareAr -> SquareAr
simplify :: SquareAr -> SquareAr
Simplifiable)
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
$c== :: Square -> Square -> Bool
== :: Square -> Square -> Bool
$c/= :: Square -> Square -> Bool
/= :: 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
$cshowsPrec :: Int -> Square -> ShowS
showsPrec :: Int -> Square -> ShowS
$cshow :: Square -> String
show :: Square -> String
$cshowList :: [Square] -> ShowS
showList :: [Square] -> ShowS
Show, (forall x. Square -> Rep Square x)
-> (forall x. Rep Square x -> Square) -> Generic Square
forall x. Rep Square x -> Square
forall x. Square -> Rep Square x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Square -> Rep Square x
from :: forall x. Square -> Rep Square x
$cto :: forall x. Rep Square x -> Square
to :: forall x. Rep Square x -> Square
Generic, Int -> Int -> String -> Square -> String
Int -> Square -> String
(Int -> Square -> String)
-> (Int -> Int -> String -> Square -> String)
-> (Int -> Square -> String)
-> PrettyPrint Square
forall a.
(Int -> a -> String)
-> (Int -> Int -> String -> a -> String)
-> (Int -> a -> String)
-> PrettyPrint a
$cpprint :: Int -> Square -> String
pprint :: Int -> Square -> String
$cpprintWithIndentations :: Int -> Int -> String -> Square -> String
pprintWithIndentations :: Int -> Int -> String -> Square -> String
$cpprintIndent :: Int -> Square -> String
pprintIndent :: Int -> Square -> String
PrettyPrint, Square -> Square
(Square -> Square) -> Simplifiable Square
forall a. (a -> a) -> Simplifiable a
$csimplify :: Square -> Square
simplify :: Square -> Square
Simplifiable)
instance Morphism SquareAr SquareOb where
source :: SquareAr -> SquareOb
source SquareAr
SquareIdA = SquareOb
SquareA
source SquareAr
SquareIdB = SquareOb
SquareB
source SquareAr
SquareIdC = SquareOb
SquareC
source SquareAr
SquareIdD = SquareOb
SquareD
source SquareAr
SquareF = SquareOb
SquareA
source SquareAr
SquareG = SquareOb
SquareA
source SquareAr
SquareH = SquareOb
SquareB
source SquareAr
SquareI = SquareOb
SquareC
source SquareAr
SquareFH = SquareOb
SquareA
source SquareAr
SquareGI = SquareOb
SquareA
target :: SquareAr -> SquareOb
target SquareAr
SquareIdA = SquareOb
SquareA
target SquareAr
SquareIdB = SquareOb
SquareB
target SquareAr
SquareIdC = SquareOb
SquareC
target SquareAr
SquareIdD = SquareOb
SquareD
target SquareAr
SquareF = SquareOb
SquareB
target SquareAr
SquareG = SquareOb
SquareC
target SquareAr
SquareH = SquareOb
SquareD
target SquareAr
SquareI = SquareOb
SquareD
target SquareAr
SquareFH = SquareOb
SquareD
target SquareAr
SquareGI = SquareOb
SquareD
@ :: SquareAr -> SquareAr -> SquareAr
(@) SquareAr
SquareIdA SquareAr
SquareIdA = SquareAr
SquareIdA
(@) SquareAr
SquareF SquareAr
SquareIdA = SquareAr
SquareF
(@) SquareAr
SquareG SquareAr
SquareIdA = SquareAr
SquareG
(@) SquareAr
SquareFH SquareAr
SquareIdA = SquareAr
SquareFH
(@) SquareAr
SquareGI SquareAr
SquareIdA = SquareAr
SquareGI
(@) SquareAr
SquareIdB SquareAr
SquareIdB = SquareAr
SquareIdB
(@) SquareAr
SquareH SquareAr
SquareIdB = SquareAr
SquareH
(@) SquareAr
SquareIdC SquareAr
SquareIdC = SquareAr
SquareIdC
(@) SquareAr
SquareI SquareAr
SquareIdC = SquareAr
SquareI
(@) SquareAr
SquareIdD SquareAr
SquareIdD = SquareAr
SquareIdD
(@) SquareAr
SquareIdB SquareAr
SquareF = SquareAr
SquareF
(@) SquareAr
SquareH SquareAr
SquareF = SquareAr
SquareFH
(@) SquareAr
SquareIdC SquareAr
SquareG = SquareAr
SquareG
(@) SquareAr
SquareI SquareAr
SquareG = SquareAr
SquareGI
(@) SquareAr
SquareIdD SquareAr
SquareH = SquareAr
SquareH
(@) SquareAr
SquareIdD SquareAr
SquareI = SquareAr
SquareI
(@) SquareAr
SquareIdD SquareAr
SquareFH = SquareAr
SquareFH
(@) SquareAr
SquareIdD SquareAr
SquareGI = SquareAr
SquareGI
(@) SquareAr
_ SquareAr
_ = String -> SquareAr
forall a. HasCallStack => String -> a
error String
"Incompatible composition of Square morphisms."
instance Category Square SquareAr SquareOb where
identity :: Morphism SquareAr SquareOb => Square -> SquareOb -> SquareAr
identity Square
_ SquareOb
SquareA = SquareAr
SquareIdA
identity Square
_ SquareOb
SquareB = SquareAr
SquareIdB
identity Square
_ SquareOb
SquareC = SquareAr
SquareIdC
identity Square
_ SquareOb
SquareD = SquareAr
SquareIdD
ar :: Morphism SquareAr SquareOb =>
Square -> SquareOb -> SquareOb -> Set SquareAr
ar Square
_ SquareOb
SquareA SquareOb
SquareA = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareIdA]
ar Square
_ SquareOb
SquareA SquareOb
SquareB = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareF]
ar Square
_ SquareOb
SquareA SquareOb
SquareC = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareG]
ar Square
_ SquareOb
SquareA SquareOb
SquareD = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareFH,SquareAr
SquareGI]
ar Square
_ SquareOb
SquareB SquareOb
SquareB = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareIdB]
ar Square
_ SquareOb
SquareB SquareOb
SquareD = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareH]
ar Square
_ SquareOb
SquareC SquareOb
SquareC = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareIdC]
ar Square
_ SquareOb
SquareC SquareOb
SquareD = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareI]
ar Square
_ SquareOb
SquareD SquareOb
SquareD = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareIdD]
ar Square
_ SquareOb
_ SquareOb
_ = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set []
genAr :: Morphism SquareAr SquareOb =>
Square -> SquareOb -> SquareOb -> Set SquareAr
genAr Square
_ SquareOb
SquareA SquareOb
SquareA = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareIdA]
genAr Square
_ SquareOb
SquareA SquareOb
SquareB = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareF]
genAr Square
_ SquareOb
SquareA SquareOb
SquareC = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareG]
genAr Square
_ SquareOb
SquareB SquareOb
SquareB = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareIdB]
genAr Square
_ SquareOb
SquareB SquareOb
SquareD = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareH]
genAr Square
_ SquareOb
SquareC SquareOb
SquareC = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareIdC]
genAr Square
_ SquareOb
SquareC SquareOb
SquareD = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareI]
genAr Square
_ SquareOb
SquareD SquareOb
SquareD = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set [SquareAr
SquareIdD]
genAr Square
_ SquareOb
_ SquareOb
_ = [SquareAr] -> Set SquareAr
forall a. [a] -> Set a
set []
decompose :: Morphism SquareAr SquareOb => Square -> SquareAr -> [SquareAr]
decompose Square
_ SquareAr
SquareFH = [SquareAr
SquareH, SquareAr
SquareF]
decompose Square
_ SquareAr
SquareGI = [SquareAr
SquareI, SquareAr
SquareG]
decompose Square
_ SquareAr
x = [SquareAr
x]
instance FiniteCategory Square SquareAr SquareOb where
ob :: Square -> Set SquareOb
ob Square
_ = [SquareOb] -> Set SquareOb
forall a. [a] -> Set a
set [SquareOb
SquareA, SquareOb
SquareB, SquareOb
SquareC, SquareOb
SquareD]