map -package:containers -package:basement -package:psqueues -package:Cabal-syntax -package:ghc -package:invertible -package:os-string -package:conduit package:unordered-containers

Transform this map by applying a function to every value.
Transform this set by applying a function to every value. The resulting set may be smaller than the source.
>>> HashSet.map show (HashSet.fromList [1,2,3])
HashSet.fromList ["1","2","3"]
mapKeys f s is the map obtained by applying f to each key of s. The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case there is no guarantee which of the associated values is chosen for the conflicting key.
>>> mapKeys (+ 1) (fromList [(5,"a"), (3,"b")])
fromList [(4,"b"),(6,"a")]

>>> mapKeys (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")])
fromList [(1,"c")]

>>> mapKeys (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")])
fromList [(3,"c")]
Transform this map by applying a function to every value and retaining only some of them.
Transform this map by applying a function to every value and retaining only some of them.
Transform this map by applying a function to every value.
Strict version of map.
A bitmap as contained by a BitmapIndexed node, or a fullBitmap corresponding to a Full node. Only the lower maxChildren bits are used. The remaining bits must be zeros.
Invariants:
  • Only the lower maxChildren bits of the Bitmap may be set. The remaining upper bits must be 0. (INV2)
  • The array of a BitmapIndexed node stores at least 1 and at most maxChildren - 1 sub-nodes. (INV3)
  • The number of sub-nodes is equal to the number of 1-bits in its Bitmap. (INV4)
  • If a BitmapIndexed node has only one sub-node, this sub-node must be a BitmapIndexed or a Full node. (INV5)
A map from keys to values. A map cannot contain duplicate keys; each key can map to at most one value.
Create a BitmapIndexed or Full node.
Common implementation for filterWithKey and mapMaybeWithKey, allowing the former to former to reuse terms.
Reduce the map by applying a function to each element and combining the results with a monoid operation.
A bitmap with the maxChildren least significant bits set, i.e. 0xFF_FF_FF_FF.
Inclusion of maps. A map is included in another map if the keys are subsets and the corresponding values are equal:
isSubmapOf m1 m2 = keys m1 `isSubsetOf` keys m2 &&
and [ v1 == v2 | (k1,v1) <- toList m1; let v2 = m2 ! k1 ]

Examples

>>> fromList [(1,'a')] `isSubmapOf` fromList [(1,'a'),(2,'b')]
True
>>> fromList [(1,'a'),(2,'b')] `isSubmapOf` fromList [(1,'a')]
False
Inclusion of maps with value comparison. A map is included in another map if the keys are subsets and if the comparison function is true for the corresponding values:
isSubmapOfBy cmpV m1 m2 = keys m1 `isSubsetOf` keys m2 &&
and [ v1 `cmpV` v2 | (k1,v1) <- toList m1; let v2 = m2 ! k1 ]

Examples

>>> isSubmapOfBy (<=) (fromList [(1,'a')]) (fromList [(1,'b'),(2,'c')])
True
>>> isSubmapOfBy (<=) (fromList [(1,'b')]) (fromList [(1,'a'),(2,'c')])
False
Convert from the equivalent HashMap with () values.
>>> HashSet.fromMap (HashMap.singleton 1 ())
fromList [1]
Convert to set to the equivalent HashMap with () values.
>>> HashSet.toMap (HashSet.singleton 1)
fromList [(1,())]