WeakSets 1.3.0.0 → 1.3.1.0
raw patch · 4 files changed
+32/−3 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Math.PureSet: first :: PureSet -> PureSet
+ Math.PureSet: second :: PureSet -> PureSet
Files
- CHANGELOG.md +5/−1
- WeakSets.cabal +1/−1
- src/Data/WeakSet.hs +1/−1
- src/Math/PureSet.hs +25/−0
CHANGELOG.md view
@@ -50,4 +50,8 @@ # 1.3.0.0 -- 2022-07-28 -* Correction of cartesianProductOfSet+* Correction of cartesianProductOfSet + +# 1.3.1.0 -- 2022-08-29 + +* Addition of first and second functions for PureSet.
WeakSets.cabal view
@@ -14,7 +14,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 1.3.0.0 +version: 1.3.1.0 -- A short (one-line) description of the package. synopsis:
src/Data/WeakSet.hs view
@@ -480,7 +480,7 @@ -- Either interactions --- | /O(n)/. Map a function to a set and separate Left and Right values. +-- | /O(n)/. Take a set of Either and separate Left and Right values. catEither :: Set (Either a b) -> (Set a, Set b) catEither (Set []) = (empty,empty) catEither (Set (x:xs))
src/Math/PureSet.hs view
@@ -24,6 +24,8 @@ emptySet, singleton, pair, + first, + second, cartesianProduct, numberToSet, (||||), @@ -68,6 +70,29 @@ -- | Construct an ordered pair from two sets according to Kuratowski's definition of a tuple. pair :: PureSet -> PureSet -> PureSet pair x y = PureSet $ set [singleton x, pureSet $ [x,y]] + + -- | Return the first element of a pair according to Kuratowski's definition of a tuple. + first :: PureSet -> PureSet + first (PureSet s) + | length l /= 2 = error $ "Math.PureSet.first : malformed pair " ++ (show s) + | otherwise = anElement f + where + l = setToList s + a = l !! 0 + b = l !! 1 + PureSet f = if card a == 1 then a else b + + -- | Return the second element of a pair according to Kuratowski's definition of a tuple. + second :: PureSet -> PureSet + second i@(PureSet s) + | length l /= 2 = error $ "Math.PureSet.second : malformed pair " ++ (show s) + | otherwise = if r2 !! 0 == first i then r2 !! 1 else r2 !! 0 + where + l = setToList s + a = l !! 0 + b = l !! 1 + PureSet r = if card a == 2 then a else b + r2 = setToList r -- | Construct the cartesian product of two sets. cartesianProduct :: PureSet -> PureSet -> PureSet