{-# LANGUAGE MultiParamTypeClasses #-}
module Math.FiniteCategories.Hat
(
HatOb(..),
HatAr(..),
Hat(..)
)
where
import Math.FiniteCategory
import Math.IO.PrettyPrint
import Data.WeakSet.Safe
data HatOb = HatA | HatB | HatC deriving (HatOb -> HatOb -> Bool
(HatOb -> HatOb -> Bool) -> (HatOb -> HatOb -> Bool) -> Eq HatOb
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HatOb -> HatOb -> Bool
== :: HatOb -> HatOb -> Bool
$c/= :: HatOb -> HatOb -> Bool
/= :: HatOb -> HatOb -> Bool
Eq, Int -> HatOb -> ShowS
[HatOb] -> ShowS
HatOb -> String
(Int -> HatOb -> ShowS)
-> (HatOb -> String) -> ([HatOb] -> ShowS) -> Show HatOb
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HatOb -> ShowS
showsPrec :: Int -> HatOb -> ShowS
$cshow :: HatOb -> String
show :: HatOb -> String
$cshowList :: [HatOb] -> ShowS
showList :: [HatOb] -> ShowS
Show)
data HatAr = HatIdA | HatIdB | HatIdC | HatF | HatG deriving (HatAr -> HatAr -> Bool
(HatAr -> HatAr -> Bool) -> (HatAr -> HatAr -> Bool) -> Eq HatAr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HatAr -> HatAr -> Bool
== :: HatAr -> HatAr -> Bool
$c/= :: HatAr -> HatAr -> Bool
/= :: HatAr -> HatAr -> Bool
Eq, Int -> HatAr -> ShowS
[HatAr] -> ShowS
HatAr -> String
(Int -> HatAr -> ShowS)
-> (HatAr -> String) -> ([HatAr] -> ShowS) -> Show HatAr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HatAr -> ShowS
showsPrec :: Int -> HatAr -> ShowS
$cshow :: HatAr -> String
show :: HatAr -> String
$cshowList :: [HatAr] -> ShowS
showList :: [HatAr] -> ShowS
Show)
data Hat = Hat deriving (Hat -> Hat -> Bool
(Hat -> Hat -> Bool) -> (Hat -> Hat -> Bool) -> Eq Hat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Hat -> Hat -> Bool
== :: Hat -> Hat -> Bool
$c/= :: Hat -> Hat -> Bool
/= :: Hat -> Hat -> Bool
Eq, Int -> Hat -> ShowS
[Hat] -> ShowS
Hat -> String
(Int -> Hat -> ShowS)
-> (Hat -> String) -> ([Hat] -> ShowS) -> Show Hat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Hat -> ShowS
showsPrec :: Int -> Hat -> ShowS
$cshow :: Hat -> String
show :: Hat -> String
$cshowList :: [Hat] -> ShowS
showList :: [Hat] -> ShowS
Show)
instance Morphism HatAr HatOb where
source :: HatAr -> HatOb
source HatAr
HatIdA = HatOb
HatA
source HatAr
HatIdB = HatOb
HatB
source HatAr
HatIdC = HatOb
HatC
source HatAr
_ = HatOb
HatA
target :: HatAr -> HatOb
target HatAr
HatIdA = HatOb
HatA
target HatAr
HatIdB = HatOb
HatB
target HatAr
HatIdC = HatOb
HatC
target HatAr
HatF = HatOb
HatB
target HatAr
HatG = HatOb
HatC
@? :: HatAr -> HatAr -> Maybe HatAr
(@?) HatAr
HatIdA HatAr
HatIdA = HatAr -> Maybe HatAr
forall a. a -> Maybe a
Just HatAr
HatIdA
(@?) HatAr
HatF HatAr
HatIdA = HatAr -> Maybe HatAr
forall a. a -> Maybe a
Just HatAr
HatF
(@?) HatAr
HatG HatAr
HatIdA = HatAr -> Maybe HatAr
forall a. a -> Maybe a
Just HatAr
HatG
(@?) HatAr
HatIdB HatAr
HatIdB = HatAr -> Maybe HatAr
forall a. a -> Maybe a
Just HatAr
HatIdB
(@?) HatAr
HatIdC HatAr
HatIdC = HatAr -> Maybe HatAr
forall a. a -> Maybe a
Just HatAr
HatIdC
(@?) HatAr
HatIdB HatAr
HatF = HatAr -> Maybe HatAr
forall a. a -> Maybe a
Just HatAr
HatF
(@?) HatAr
HatIdC HatAr
HatG = HatAr -> Maybe HatAr
forall a. a -> Maybe a
Just HatAr
HatG
(@?) HatAr
_ HatAr
_ = Maybe HatAr
forall a. Maybe a
Nothing
instance Category Hat HatAr HatOb where
identity :: Morphism HatAr HatOb => Hat -> HatOb -> HatAr
identity Hat
_ HatOb
HatA = HatAr
HatIdA
identity Hat
_ HatOb
HatB = HatAr
HatIdB
identity Hat
_ HatOb
HatC = HatAr
HatIdC
ar :: Morphism HatAr HatOb => Hat -> HatOb -> HatOb -> Set HatAr
ar Hat
_ HatOb
HatA HatOb
HatA = [HatAr] -> Set HatAr
forall a. [a] -> Set a
set [HatAr
HatIdA]
ar Hat
_ HatOb
HatB HatOb
HatB = [HatAr] -> Set HatAr
forall a. [a] -> Set a
set [HatAr
HatIdB]
ar Hat
_ HatOb
HatC HatOb
HatC = [HatAr] -> Set HatAr
forall a. [a] -> Set a
set [HatAr
HatIdC]
ar Hat
_ HatOb
HatA HatOb
HatB = [HatAr] -> Set HatAr
forall a. [a] -> Set a
set [HatAr
HatF]
ar Hat
_ HatOb
HatA HatOb
HatC = [HatAr] -> Set HatAr
forall a. [a] -> Set a
set [HatAr
HatG]
ar Hat
_ HatOb
_ HatOb
_ = [HatAr] -> Set HatAr
forall a. [a] -> Set a
set []
instance FiniteCategory Hat HatAr HatOb where
ob :: Hat -> Set HatOb
ob Hat
_ = [HatOb] -> Set HatOb
forall a. [a] -> Set a
set [HatOb
HatA, HatOb
HatB, HatOb
HatC]
instance PrettyPrint HatOb where
pprint :: HatOb -> String
pprint HatOb
HatA = String
"A"
pprint HatOb
HatB = String
"B"
pprint HatOb
HatC = String
"C"
instance PrettyPrint HatAr where
pprint :: HatAr -> String
pprint HatAr
HatIdA = String
"IdA"
pprint HatAr
HatIdB = String
"IdB"
pprint HatAr
HatIdC = String
"IdC"
pprint HatAr
HatF = String
"f"
pprint HatAr
HatG = String
"g"
instance PrettyPrint Hat where
pprint :: Hat -> String
pprint = Hat -> String
forall a. Show a => a -> String
show