WeakSets 1.2.0.0 → 1.2.2.0
raw patch · 6 files changed
+26/−3 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.WeakMap: enumerateMaps :: (Eq a, Eq b) => Set a -> Set b -> Set (Map a b)
+ Data.WeakMap.Safe: enumerateMaps :: (Eq a, Eq b) => Set a -> Set b -> Set (Map a b)
+ Data.WeakSet: anElement :: Set a -> a
+ Data.WeakSet.Safe: anElement :: Set a -> a
Files
- CHANGELOG.md +9/−1
- WeakSets.cabal +1/−1
- src/Data/WeakMap.hs +7/−0
- src/Data/WeakMap/Safe.hs +1/−0
- src/Data/WeakSet.hs +7/−1
- src/Data/WeakSet/Safe.hs +1/−0
CHANGELOG.md view
@@ -30,4 +30,12 @@ # 1.2.0.0 -- 2022-07-20 -* Major bug correction : instance Foldable removed for Data.WeakMap and Data.WeakSet+* Major bug correction : instance Foldable removed for Data.WeakMap and Data.WeakSet + +# 1.2.1.0 -- 2022-07-23 + +* Adding anElement function + +# 1.2.2.0 -- 2022-07-24 + +* Adding enumerateMaps function
WeakSets.cabal view
@@ -14,7 +14,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 1.2.0.0 +version: 1.2.2.0 -- A short (one-line) description of the package. synopsis:
src/Data/WeakMap.hs view
@@ -212,6 +212,7 @@ , memorizeFunction , inverse , pseudoInverse + , enumerateMaps ) where import Prelude hiding (lookup, map, filter, drop, take, splitAt, foldr, foldl, null) import Data.WeakSet (Set) @@ -939,3 +940,9 @@ pseudoInverse :: Map k v -> Map v k pseudoInverse (Map al) = Map $ (\(k,v) -> (v,k)) <$> al +-- | Return all Functions from a domain to a codomain. +enumerateMaps :: (Eq a, Eq b) => + Set a -- ^ Domain. + -> Set b -- ^ Codomain. + -> Set (Map a b) -- ^ All maps from domain to codomain. +enumerateMaps dom codom = set $ weakMap <$> zip (setToList dom) <$> setToList (codom |^| (cardinal dom))
src/Data/WeakMap/Safe.hs view
@@ -24,6 +24,7 @@ , image , inverse , pseudoInverse + , enumerateMaps ) where import Data.WeakMap
src/Data/WeakSet.hs view
@@ -145,6 +145,7 @@ -- * Others , traverseSet , sequenceSet + , anElement ) where import Prelude hiding (filter, splitAt, drop, take, map, foldr, foldl, null, and, or) @@ -543,4 +544,9 @@ -- | Disjunction of a set of booleans. or :: Set Bool -> Bool -or (Set xs) = Foldable.or xs+or (Set xs) = Foldable.or xs + +-- | /O(1)/. Returns an element of the set if it is not empty, throw an error otherwise. +anElement :: Set a -> a +anElement (Set []) = error "Data.WeakSet.anElement: empty set" +anElement (Set (x:xs)) = x
src/Data/WeakSet/Safe.hs view
@@ -24,6 +24,7 @@ (|-|), (|^|), nubSetBy, + anElement, ) where import Data.WeakSet