packages feed

WeakSets 1.1.1.0 → 1.1.2.0

raw patch · 4 files changed

+14/−3 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.WeakMap: weakMapFromSet :: Set (k, v) -> Map k v
+ Data.WeakMap.Safe: weakMapFromSet :: Set (k, v) -> Map k v

Files

CHANGELOG.md view
@@ -14,4 +14,8 @@ 
 # 1.1.1.0 -- 2022-07-19
 
-* Implementation of drop, take and splitAt+* Implementation of drop, take and splitAt
+
+# 1.1.2.0 -- 2022-07-19
+
+* Addition of weakMapFromSet and correction of WeakMap Show instance.
WeakSets.cabal view
@@ -14,7 +14,7 @@ -- PVP summary:      +-+------- breaking API changes
 --                   | | +----- non-breaking API additions
 --                   | | | +--- code changes with no API change
-version:            1.1.1.0
+version:            1.1.2.0
 
 -- A short (one-line) description of the package.
 synopsis:
src/Data/WeakMap.hs view
@@ -51,6 +51,7 @@ 
     -- * Construction
     , weakMap
+    , weakMapFromSet
     , empty
     , singleton
     , fromSet
@@ -225,7 +226,9 @@ data Map k v = Map {-# UNPACK #-} !(Set (k,v)) deriving (Eq)
 
 instance (Show k, Show v) => Show (Map k v) where
-    show (Map al) = "(weakMap "++show al++")"
+    show (Map al) = "(weakMap "++ init rest ++")"
+        where
+            ('(':'s':'e':'t':' ':rest)= show al
 
 instance Semigroup (Map k v) where
     (Map al1) <> (Map al2) = Map $ al1 <> al2
@@ -249,6 +252,9 @@ -- If several pairs have the same keys, they are kept until the user wants an association list back.
 weakMap :: AssociationList k v -> Map k v
 weakMap al = Map $ set $ al
+
+weakMapFromSet :: Set (k,v) -> Map k v
+weakMapFromSet s = Map s
 
 -- | /O(1)/. Alias of `weakMap` for backward compatibility with Data.Map.
 fromList :: AssociationList k v -> Map k v
src/Data/WeakMap/Safe.hs view
@@ -12,6 +12,7 @@ module Data.WeakMap.Safe
 (
     weakMap -- the smart constructor for `Map`
+    ,  weakMapFromSet
     , (|?|)
     , (|!|)
     , (|.|)