packages feed

FiniteCategories 0.6.0.2 → 0.6.1.0

raw patch · 3 files changed

+23/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Math.Categories.FinSketch: checkFiniteSketch :: (Eq n, Eq e) => Sketch n e -> Maybe (SketchError n e)

Files

CHANGELOG.md view
@@ -34,4 +34,8 @@ 
 ## 0.6.0.2 -- 2024-01-22
 
-* Bug fix in checkNaturalTransformation.+* Bug fix in checkNaturalTransformation.
+
+## 0.6.1.0 -- 2024-01-23
+
+* Add checkFiniteSketch to be more specific.
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.0.2
+version:             0.6.1.0
 
 -- A short (one-line) description of the package.
 synopsis: Finite categories and usual categorical constructions on them.
src/Math/Categories/FinSketch.hs view
@@ -44,6 +44,7 @@     sketchText,     -- ** Helpers     checkSketch,+    checkFiniteSketch,     -- * Sketch morphism,     SketchMorphism,     SketchMorphismError(..),@@ -179,7 +180,7 @@         where             filtered = Set.filter p s -    -- | Smart constructor for a 'Sketch'. Note that for each distinguished 'Tripod', the 2-cone of the 'Tripod' is added to the distinguished 'cones' of the sketch. The two first arguments are arbitrary distinct objects of type n which will be the indexing objects of the new 2-cones.+    -- | Smart constructor for a finite 'Sketch'. Note that for each distinguished 'Tripod', the 2-cone of the 'Tripod' is added to the distinguished 'cones' of the sketch. The two first arguments are arbitrary distinct objects of type n which will be the indexing objects of the new 2-cones.     sketch :: (Eq n, Eq e) => n -> n -> CategorySketch n e -> (Set (ConeSketch n e)) -> (Set (CoconeSketch n e)) -> (Set (TripodSketch n e)) -> Either (SketchError n e) (Sketch n e)     sketch a b cat c cc t         | not $ null $ errCat = Left $ UnderlyingCategoryError $ fromJust errCat@@ -201,9 +202,23 @@     sketchText :: CategorySketch Text Text -> (Set (ConeSketch Text Text)) -> (Set (CoconeSketch Text Text)) -> (Set (TripodSketch Text Text)) -> Either (SketchError Text Text) (Sketch Text Text)     sketchText = sketch (pack "A") (pack "B")        -    -- | Check wether a 'Sketch' is well formed or not, return a 'SketchError' if it is malformed, Nothing otherwise.+    -- | Check wether a 'Sketch' is well formed or not, return a 'SketchError' if it is malformed, Nothing otherwise. Does not check the underlying 'CompositionGraph'.     checkSketch :: (Eq n, Eq e) => Sketch n e -> Maybe (SketchError n e)     checkSketch Sketch{underlyingCategory = cat, distinguishedCones = c, distinguishedCocones = cc, distinguishedTripods = t}+        | not $ null $ faultyCone = BaseOfConeIsNotInUnderlyingCategory <$> faultyCone +        | not $ null $ faultyCocone = BaseOfCoconeIsNotInUnderlyingCategory <$> faultyCocone+        | not $ null $ faultyTripod = BaseOfTripodIsNotInUnderlyingCategory <$> faultyTripod+        | not $ null $ faultyTripod2 = TripodTwoConeDoesNotBelongToDistinguishedCones <$> faultyTripod2+        | otherwise = Nothing+        where+            faultyCone = find (\x -> universeCategoryCone x /= cat) c+            faultyCocone = find (\x -> universeCategoryCocone x /= cat) cc+            faultyTripod = find (\x -> universeCategoryTripod x /= cat) t+            faultyTripod2 = find (\x -> not $ Set.or [apex cone == (apex $ twoCone x) && (cardinal $ ob $ indexingCategoryCone cone) == 2 && (cardinal $ arrows $ indexingCategoryCone cone) == 2 && (target <$> Map.values (components $ legsCone cone)) == set [powerObject x, internalDomain x] | cone <- c]) t+       +    -- | Check wether a finite 'Sketch' is well formed or not, return a 'SketchError' if it is malformed, Nothing otherwise.+    checkFiniteSketch :: (Eq n, Eq e) => Sketch n e -> Maybe (SketchError n e)+    checkFiniteSketch Sketch{underlyingCategory = cat, distinguishedCones = c, distinguishedCocones = cc, distinguishedTripods = t}         | not $ null $ errCat = UnderlyingCategoryError <$> errCat         | not $ null $ faultyCone = BaseOfConeIsNotInUnderlyingCategory <$> faultyCone          | not $ null $ faultyCocone = BaseOfCoconeIsNotInUnderlyingCategory <$> faultyCocone