module Math.FiniteCategories.SafeCompositionGraph.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 Numeric.Natural
import System.Random
main :: IO ()
main :: IO ()
main = do
String -> IO ()
putStrLn String
"Start of Math.FiniteCategories.SafeCompositionGraph.Example"
SafeCompositionGraph 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 -> Int -> SafeCompositionGraph Int Char
forall a b.
Graph a b -> CompositionLaw a b -> Int -> SafeCompositionGraph a b
unsafeSafeCompositionGraph (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'}])]) Int
3) String
"OutputGraphViz/Examples/FiniteCategories/SafeCompositionGraph/SafeCompositionGraph"
SafeCompositionGraph 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 -> Int -> SafeCompositionGraph Int Char
forall a b.
Graph a b -> CompositionLaw a b -> Int -> SafeCompositionGraph a b
unsafeSafeCompositionGraph (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]) ([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'}])) (AssociationList [Arrow Int Char] [Arrow Int Char]
-> CompositionLaw Int Char
forall k v. AssociationList k v -> Map k v
weakMap []) Int
3) String
"OutputGraphViz/Examples/FiniteCategories/SafeCompositionGraph/SafeCompositionGraphOnFreeMonoid"
SafeCompositionGraph 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 ((SafeCompositionGraph Int Int, StdGen)
-> SafeCompositionGraph Int Int
forall a b. (a, b) -> a
fst((SafeCompositionGraph Int Int, StdGen)
-> SafeCompositionGraph Int Int)
-> (StdGen -> (SafeCompositionGraph Int Int, StdGen))
-> StdGen
-> SafeCompositionGraph Int Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
.StdGen -> (SafeCompositionGraph Int Int, StdGen)
forall g. RandomGen g => g -> (SafeCompositionGraph Int Int, g)
defaultConstructRandomSafeCompositionGraph (StdGen -> SafeCompositionGraph Int Int)
-> StdGen -> SafeCompositionGraph Int Int
forall a b. (a -> b) -> a -> b
$ (Int -> StdGen
mkStdGen Int
123456)) String
"OutputGraphViz/Examples/FiniteCategories/SafeCompositionGraph/RandomSafeCompositionGraph"
let (Right SCG
scg) = String
-> Either (FiniteCategoryError (SCGMorphism Text Text) Text) SCG
readSCGString String
"2\nA -f-> B -g-> C = A -h-> C"
SCG -> String -> IO ()
forall o m c.
(Eq o, PrettyPrint o, PrettyPrint m, Morphism m o,
FiniteCategory c m o) =>
c -> String -> IO ()
catToPdf SCG
scg String
"OutputGraphViz/Examples/FiniteCategories/SafeCompositionGraph/SafeCompositionGraphFromString"
String -> IO ()
putStrLn String
"End of Math.FiniteCategories.SafeCompositionGraph.Example"