chatter-0.8.0.2: A library of simple NLP algorithms.

Safe HaskellNone
LanguageHaskell2010

Data.DefaultMap

Synopsis

Documentation

data DefaultMap k v Source

Defaulting Map; a Map that returns a default value when queried for a key that does not exist.

Constructors

DefMap 

Fields

defDefault :: v
 
defMap :: HashMap k v
 

Instances

empty :: v -> DefaultMap k v Source

Create an empty DefaultMap

lookup :: (Eq k, Hashable k) => k -> DefaultMap k v -> v Source

Query the map for a value. Returns the default if the key is not found.

fromList :: (Eq k, Hashable k) => v -> [(k, v)] -> DefaultMap k v Source

Create a DefaultMap from a default value and a list.

keys :: DefaultMap k a -> [k] Source

Access the keys as a list.

elems :: DefaultMap k a -> [a] Source

Access the non-default values as a list.

map :: (a -> a) -> DefaultMap k a -> DefaultMap k a Source

Map a function over the values in a map.

foldl :: (a -> b -> a) -> a -> DefaultMap k b -> a Source

Fold over the values in the map.

Note that this *does* not fold over the default value -- this fold behaves in the same way as a standard foldl

unionWith Source

Arguments

:: (Eq k, Hashable k) 
=> (v -> v -> v)

Combine values with this function

-> v

The new map's default value

-> DefaultMap k v

The first map to combine

-> DefaultMap k v

The second map to combine

-> DefaultMap k v 

Compute the union of two maps using the specified per-value combination function and the specified new map default value.