module Math.FiniteCategories.CompositionGraph.Example
(
main
)
where
import qualified Data.WeakSet as Set
import Data.WeakSet.Safe
import Data.WeakMap.Safe
import Math.FiniteCategory
import Math.Categories
import Math.FiniteCategories
import Math.IO.FiniteCategories.ExportGraphViz
import Math.IO.PrettyPrint
import System.Random
import Numeric.Natural
main :: IO ()
main :: IO ()
main = do
String -> IO ()
putStrLn String
"Start of Math.FiniteCategories.CompositionGraph.Example"
CompositionGraph Int Char -> String -> IO ()
forall o m c.
(Eq o, PrettyPrint o, PrettyPrint m, Morphism m o,
FiniteCategory c m o) =>
c -> String -> IO ()
catToPdf (Graph Int Char
-> CompositionLaw Int Char -> CompositionGraph Int Char
forall a b. Graph a b -> CompositionLaw a b -> CompositionGraph a b
unsafeCompositionGraph (Set Int -> Set (Arrow Int Char) -> Graph Int Char
forall n e. Set n -> Set (Arrow n e) -> Graph n e
unsafeGraph ([Int] -> Set Int
forall a. [a] -> Set a
set [Int
1 :: Int,Int
2,Int
3]) ([Arrow Int Char] -> Set (Arrow Int Char)
forall a. [a] -> Set a
set [Arrow :: forall n e. n -> n -> e -> Arrow n e
Arrow{sourceArrow :: Int
sourceArrow=Int
1,targetArrow :: Int
targetArrow=Int
1,labelArrow :: Char
labelArrow=Char
'a'},Arrow :: forall n e. n -> n -> e -> Arrow n e
Arrow{sourceArrow :: Int
sourceArrow=Int
1,targetArrow :: Int
targetArrow=Int
2,labelArrow :: Char
labelArrow=Char
'b'},Arrow :: forall n e. n -> n -> e -> Arrow n e
Arrow{sourceArrow :: Int
sourceArrow=Int
2,targetArrow :: Int
targetArrow=Int
3,labelArrow :: Char
labelArrow=Char
'c'}])) (AssociationList [Arrow Int Char] [Arrow Int Char]
-> CompositionLaw Int Char
forall k v. AssociationList k v -> Map k v
weakMap [([Arrow :: forall n e. n -> n -> e -> Arrow n e
Arrow{sourceArrow :: Int
sourceArrow=Int
1,targetArrow :: Int
targetArrow=Int
1,labelArrow :: Char
labelArrow=Char
'a'},Arrow :: forall n e. n -> n -> e -> Arrow n e
Arrow{sourceArrow :: Int
sourceArrow=Int
1,targetArrow :: Int
targetArrow=Int
1,labelArrow :: Char
labelArrow=Char
'a'}],[Arrow :: forall n e. n -> n -> e -> Arrow n e
Arrow{sourceArrow :: Int
sourceArrow=Int
1,targetArrow :: Int
targetArrow=Int
1,labelArrow :: Char
labelArrow=Char
'a'}])])) String
"OutputGraphViz/Examples/FiniteCategories/CompositionGraph/CompositionGraph"
Diagram
(Ens Char)
(Function Char)
(Set Char)
(CompositionGraph (Set Char) (Function Char))
(CGMorphism (Set Char) (Function Char))
(Set Char)
-> String -> IO ()
forall m1 o1 c1 m2 o2 c2.
(Morphism m1 o1, FiniteCategory c1 m1 o1, Eq o1, Eq m1,
PrettyPrint m1, PrettyPrint o1, Morphism m2 o2,
FiniteCategory c2 m2 o2, Eq o2, Eq m2, PrettyPrint m2,
PrettyPrint o2) =>
Diagram c1 m1 o1 c2 m2 o2 -> String -> IO ()
diagToPdf2 (Ens Char
-> Diagram
(Ens Char)
(Function Char)
(Set Char)
(CompositionGraph (Set Char) (Function Char))
(CGMorphism (Set Char) (Function Char))
(Set Char)
forall c m o.
(FiniteCategory c m o, Morphism m o, Eq m, Eq o) =>
c -> Diagram c m o (CompositionGraph o m) (CGMorphism o m) o
finiteCategoryToCompositionGraph (Set (Set Char) -> Ens Char
forall a. Set (Set a) -> Ens a
ens(Set (Set Char) -> Ens Char)
-> (String -> Set (Set Char)) -> String -> Ens Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Set Char -> Set (Set Char)
forall a. Set a -> Set (Set a)
Set.powerSet)(Set Char -> Set (Set Char))
-> (String -> Set Char) -> String -> Set (Set Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.String -> Set Char
forall a. [a] -> Set a
set (String -> Ens Char) -> String -> Ens Char
forall a b. (a -> b) -> a -> b
$ String
"AB")) String
"OutputGraphViz/Examples/FiniteCategories/CompositionGraph/EnsToCompositionGraph"
Diagram
NumberCategory
(IsSmallerThan Natural)
Natural
(CompositionGraph Natural (IsSmallerThan Natural))
(CGMorphism Natural (IsSmallerThan Natural))
Natural
-> String -> IO ()
forall m1 o1 c1 m2 o2 c2.
(Morphism m1 o1, FiniteCategory c1 m1 o1, Eq o1, Eq m1,
PrettyPrint m1, PrettyPrint o1, Morphism m2 o2,
FiniteCategory c2 m2 o2, Eq o2, Eq m2, PrettyPrint m2,
PrettyPrint o2) =>
Diagram c1 m1 o1 c2 m2 o2 -> String -> IO ()
diagToPdf2 (NumberCategory
-> Diagram
NumberCategory
(IsSmallerThan Natural)
Natural
(CompositionGraph Natural (IsSmallerThan Natural))
(CGMorphism Natural (IsSmallerThan Natural))
Natural
forall c m o.
(FiniteCategory c m o, Morphism m o, Eq m, Eq o) =>
c -> Diagram c m o (CompositionGraph o m) (CGMorphism o m) o
finiteCategoryToCompositionGraph (Natural -> NumberCategory
numberCategory Natural
4)) String
"OutputGraphViz/Examples/FiniteCategories/CompositionGraph/NumberCategoryToCompositionGraph"
CompositionGraph Int Int -> String -> IO ()
forall o m c.
(Eq o, PrettyPrint o, PrettyPrint m, Morphism m o,
FiniteCategory c m o) =>
c -> String -> IO ()
catToPdf ((CompositionGraph Int Int, StdGen) -> CompositionGraph Int Int
forall a b. (a, b) -> a
fst((CompositionGraph Int Int, StdGen) -> CompositionGraph Int Int)
-> (StdGen -> (CompositionGraph Int Int, StdGen))
-> StdGen
-> CompositionGraph Int Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
.StdGen -> (CompositionGraph Int Int, StdGen)
forall g. RandomGen g => g -> (CompositionGraph Int Int, g)
defaultConstructRandomCompositionGraph (StdGen -> CompositionGraph Int Int)
-> StdGen -> CompositionGraph Int Int
forall a b. (a -> b) -> a -> b
$ (Int -> StdGen
mkStdGen Int
123456)) String
"OutputGraphViz/Examples/FiniteCategories/CompositionGraph/RandomCompositionGraph"
Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
-> String -> IO ()
forall m1 o1 c1 m2 o2 c2.
(Morphism m1 o1, FiniteCategory c1 m1 o1, Eq o1, Eq m1,
PrettyPrint m1, PrettyPrint o1, Morphism m2 o2,
FiniteCategory c2 m2 o2, Eq o2, Eq m2, PrettyPrint m2,
PrettyPrint o2) =>
Diagram c1 m1 o1 c2 m2 o2 -> String -> IO ()
diagToPdf2 ((Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int,
StdGen)
-> Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
forall a b. (a, b) -> a
fst((Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int,
StdGen)
-> Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int)
-> (StdGen
-> (Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int,
StdGen))
-> StdGen
-> Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
.StdGen
-> (Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int,
StdGen)
forall g.
RandomGen g =>
g
-> (Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int,
g)
defaultConstructRandomDiagram (StdGen
-> Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int)
-> StdGen
-> Diagram
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
(CompositionGraph Int Int)
(CGMorphism Int Int)
Int
forall a b. (a -> b) -> a -> b
$ (Int -> StdGen
mkStdGen Int
12345678)) String
"OutputGraphViz/Examples/FiniteCategories/CompositionGraph/RandomDiagram"
let (Right CG
cg) = String
-> Either (FiniteCategoryError (CGMorphism Text Text) Text) CG
readCGString String
"A -f-> B -g-> C = A -h-> C"
CG -> String -> IO ()
forall o m c.
(Eq o, PrettyPrint o, PrettyPrint m, Morphism m o,
FiniteCategory c m o) =>
c -> String -> IO ()
catToPdf CG
cg String
"OutputGraphViz/Examples/FiniteCategories/CompositionGraph/CompositionGraphFromString"
String -> IO ()
putStrLn String
"End of Math.FiniteCategories.CompositionGraph.Example"