Data.HashMap
- Package
- purescript-unordered-collections
- Repository
- fehrenbach/purescript-unordered-collections
#HashMap Source
data HashMap :: Type -> Type -> TypeImmutable hash maps from keys k to values v.
Note that this is an unordered collection.
Instances
(Eq k, Eq v) => Eq (HashMap k v)(Hashable k, Hashable v) => Hashable (HashMap k v)(Hashable k) => Monoid (HashMap k v)(Hashable k) => Semigroup (HashMap k v)Functor (HashMap k)FunctorWithIndex k (HashMap k)Foldable (HashMap k)The
Foldableinstance is best used with a commutative function/Monoid, since hash maps do not guarantee any particular order.FoldableWithIndex k (HashMap k)The
FoldableWithIndexinstance is best used with a commutative function/Monoid, since hash maps do not guarantee any particular order.Traversable (HashMap k)TraversableWithIndex k (HashMap k)(Show k, Show v) => Show (HashMap k v)
#fromFoldable Source
fromFoldable :: forall v k f. Foldable f => Hashable k => f (Tuple k v) -> HashMap k vTurn a foldable functor of pairs into a hash map.
In the presence of duplicate keys, later (by foldl) mappings
overwrite earlier mappings.
#fromFoldableBy Source
fromFoldableBy :: forall v k a f. Foldable f => Hashable k => (a -> k) -> (a -> v) -> f a -> HashMap k v#intersection Source
intersection :: forall v k. Hashable k => HashMap k v -> HashMap k v -> HashMap k vIntersect two maps.
For duplicate keys, we keep the value from the right map.
This is the same as Semigroup.append aka (<>).
#intersectionWith Source
intersectionWith :: forall v k. Hashable k => (v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k vIntersect two maps, combining the values for keys that appear in both maps using the given function.
intersectionWith (-) (singleton 0 3) (singleton 0 2) == singleton 0 1
- Modules
- Data.
HashMap - Data.
HashSet - Data.
Hashable
This is "the shallow" semigroup instance, where maps themselves are combined using
unionrather than elements being combined. For duplicate keys, values from the left map are preserved.