| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Map.Monoidal.Strict
Contents
Description
This module provides a Map variant which uses the value's
Monoid instance to accumulate conflicting entries when merging
Maps.
While some functions mirroring those of Map are provided
here for convenience, more specialized needs will likely want to use
either the Newtype or Wrapped instances to manipulate the
underlying Map.
- newtype MonoidalMap k a = MonoidalMap {
- getMonoidalMap :: Map k a
- singleton :: Ord k => k -> a -> MonoidalMap k a
- size :: MonoidalMap k a -> Int
- member :: Ord k => k -> MonoidalMap k a -> Bool
- notMember :: Ord k => k -> MonoidalMap k a -> Bool
- findWithDefault :: Ord k => a -> k -> MonoidalMap k a -> a
- assocs :: MonoidalMap k a -> [(k, a)]
- elems :: MonoidalMap k a -> [a]
- keys :: MonoidalMap k a -> [k]
Documentation
newtype MonoidalMap k a Source #
A Map with monoidal accumulation
Constructors
| MonoidalMap | |
Fields
| |
Instances
Often-needed functions
singleton :: Ord k => k -> a -> MonoidalMap k a Source #
O(1). A map with a single element.
size :: MonoidalMap k a -> Int Source #
O(1). The number of elements in the map.
member :: Ord k => k -> MonoidalMap k a -> Bool Source #
O(log n). Is the key a member of the map? See also notMember.
notMember :: Ord k => k -> MonoidalMap k a -> Bool Source #
O(log n). Is the key not a member of the map? See also member.
findWithDefault :: Ord k => a -> k -> MonoidalMap k a -> a Source #
O(log n). The expression ( returns
the value at key findWithDefault def k map)k or returns default value def
when the key is not in the map.
assocs :: MonoidalMap k a -> [(k, a)] Source #
O(n). Return all elements of the map and their keys
elems :: MonoidalMap k a -> [a] Source #
O(n). Return all elements of the map in the ascending order of their keys. Subject to list fusion.
keys :: MonoidalMap k a -> [k] Source #
O(n). Return all keys of the map in ascending order. Subject to list fusion.