FiniteCategories 0.6.1.1 → 0.6.2.0
raw patch · 3 files changed
+27/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Math.FiniteCategories.CompositionGraph: mapOnArrows2 :: (Eq n, Eq e1) => (e1 -> e2) -> CompositionGraph n e1 -> Diagram (CompositionGraph n e1) (CGMorphism n e1) n (CompositionGraph n e2) (CGMorphism n e2) n
+ Math.FiniteCategories.CompositionGraph: mapOnObjects2 :: (Eq n1, Eq e) => (n1 -> n2) -> CompositionGraph n1 e -> Diagram (CompositionGraph n1 e) (CGMorphism n1 e) n1 (CompositionGraph n2 e) (CGMorphism n2 e) n2
Files
CHANGELOG.md view
@@ -42,4 +42,8 @@ ## 0.6.1.1 -- 2024-01-23 -* Bug fix in sketchMorphism+* Bug fix in sketchMorphism + +## 0.6.2.0 -- 2024-01-24 + +* Add mapOnObjects2 and mapOnArrows2
FiniteCategories.cabal view
@@ -14,7 +14,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.6.1.1 +version: 0.6.2.0 -- A short (one-line) description of the package. synopsis: Finite categories and usual categorical constructions on them.
src/Math/FiniteCategories/CompositionGraph.hs view
@@ -60,7 +60,9 @@ readCGFile, -- * Transformation mapOnObjects, + mapOnObjects2, mapOnArrows, + mapOnArrows2, -- * Serialization writeCGString, writeCGFile, @@ -880,6 +882,14 @@ transformRawPath [] = [] transformRawPath (a:xs) = Arrow{sourceArrow = transformObj $ sourceArrow a, targetArrow = transformObj $ targetArrow a, labelArrow = labelArrow a} : (transformRawPath xs) + -- | Map a function on objects of the 'CompositionGraph', return the diagram from the original 'CompositionGraph' to the new one. + mapOnObjects2 :: (Eq n1, Eq e) => (n1 -> n2) -> CompositionGraph n1 e -> Diagram (CompositionGraph n1 e) (CGMorphism n1 e) n1 (CompositionGraph n2 e) (CGMorphism n2 e) n2 + mapOnObjects2 transformObj cg = Diagram{src = cg, tgt = mapOnObjects transformObj cg, omap = memorizeFunction transformObj (ob cg), mmap = memorizeFunction transformGenArrow (genArrows cg)} + where + transformGenArrow CGMorphism{path = (s,rp), compositionLaw = l} = CGMorphism{path = (transformObj s,transformRawPath rp), compositionLaw = transformLaw l} + transformLaw l = Map.weakMapFromSet [(transformRawPath k, transformRawPath v) | (k,v) <- Map.mapToSet l] + transformRawPath [] = [] + transformRawPath (a:xs) = Arrow{sourceArrow = transformObj $ sourceArrow a, targetArrow = transformObj $ targetArrow a, labelArrow = labelArrow a} : (transformRawPath xs) -- | Map a function on arrows of the 'CompositionGraph'. mapOnArrows :: (Eq n, Eq e1) => (e1 -> e2) -> CompositionGraph n e1 -> CompositionGraph n e2 @@ -887,4 +897,14 @@ where transformLaw l = Map.weakMapFromSet [(transformRawPath k, transformRawPath v) | (k,v) <- Map.mapToSet l] transformRawPath [] = [] - transformRawPath (a:xs) = Arrow{sourceArrow = sourceArrow a, targetArrow = targetArrow a, labelArrow = transformArrow $ labelArrow a} : (transformRawPath xs)+ transformRawPath (a:xs) = Arrow{sourceArrow = sourceArrow a, targetArrow = targetArrow a, labelArrow = transformArrow $ labelArrow a} : (transformRawPath xs) + + -- | Map a function on arrows of the 'CompositionGraph', return the diagram from the original 'CompositionGraph' to the new one. + mapOnArrows2 :: (Eq n, Eq e1) => (e1 -> e2) -> CompositionGraph n e1 -> Diagram (CompositionGraph n e1) (CGMorphism n e1) n (CompositionGraph n e2) (CGMorphism n e2) n + mapOnArrows2 transformArrow cg = Diagram{src = cg, tgt = mapOnArrows transformArrow cg, omap = memorizeFunction id (ob cg), mmap = memorizeFunction transformGenArrow (genArrows cg)} + where + transformLaw l = Map.weakMapFromSet [(transformRawPath k, transformRawPath v) | (k,v) <- Map.mapToSet l] + transformRawPath [] = [] + transformRawPath (a:xs) = Arrow{sourceArrow = sourceArrow a, targetArrow = targetArrow a, labelArrow = transformArrow $ labelArrow a} : (transformRawPath xs) + transformGenArrow CGMorphism{path = (s,rp), compositionLaw = l} = CGMorphism{path = (s,transformRawPath rp), compositionLaw = transformLaw l} +