packages feed

FiniteCategories-0.1.0.0: test/ExampleConeCategory/ExampleLimit.hs

{-| Module  : FiniteCategories
Description : An example of limits of a diagram.
Copyright   : Guillaume Sabbagh 2021
License     : GPL-3
Maintainer  : guillaumesabbagh@protonmail.com
Stability   : experimental
Portability : portable

An example of limits of a diagram.
-}
module ExampleConeCategory.ExampleLimit
(
    main
)
where
    import              RandomCompositionGraph.RandomCompositionGraph
    import              System.Random                                   
    import              ExportGraphViz.ExportGraphViz
    import              FiniteCategory.FiniteCategory
    import              FunctorCategory.FunctorCategory
    import              Diagram.Diagram
    import              UsualCategories.Three
    import              Utils.Sample
    import              ConeCategory.ConeCategory

    (rcg,newGen) = (mkRandomCompositionGraph 20 25 5 (mkStdGen 878))
    
    (diag,newGen1) = (pickOne (ob FunctorCategory{sourceCat=Three, targetCat=rcg}) newGen)
    
    limit = limits diag
    
    recuNatToPdf [] = putStrLn "End of natural transformation export"
    recuNatToPdf (x:xs) = do
                            natToPdf (coneToNaturalTransformation x) ("OutputGraphViz/Examples/ConeCategory/Limit/nat"++show (length xs))
                            recuNatToPdf xs

    -- | Export the limits as a pdf with GraphViz.
    main = do 
        putStrLn "Start of ExampleLimit"
        catToPdf rcg "OutputGraphViz/Examples/ConeCategory/Limit/rcg"
        diagToPdf diag "OutputGraphViz/Examples/ConeCategory/Limit/funct"
        diagToPdf2 diag "OutputGraphViz/Examples/ConeCategory/Limit/diag"
        recuNatToPdf limit
        putStrLn "End of ExampleLimit"