Copyright | © Mike Meyer, 2015 |
---|---|

License | BSD3 |

Maintainer | mwm@mired.org |

Stability | experimental |

Safe Haskell | Safe-Inferred |

Language | Haskell2010 |

A module to encapsulate associative lists.

- data AList key value
- fromList :: [(k, v)] -> AList k v
- toList :: AList k v -> [(k, v)]
- toMap :: Ord k => AList k v -> Map k v
- fromMap :: Ord k => Map k v -> AList k v
- isEmpty :: AList k v -> Bool
- lookupAll :: Eq k => k -> AList k v -> [v]
- lookupFirst :: Eq k => k -> AList k v -> Maybe v
- lookupBy :: (k -> Bool) -> AList k v -> AList k v
- member :: Eq k => k -> AList k v -> Bool
- values :: AList k v -> [v]
- keys :: AList k v -> [k]
- insert :: k -> v -> AList k v -> AList k v
- append :: k -> v -> AList k v -> AList k v
- deleteAll :: Eq k => k -> AList k v -> AList k v
- deleteFirst :: Eq k => k -> AList k v -> AList k v
- deleteBy :: (k -> Bool) -> AList k v -> AList k v

# Data

An `AList`

is a list of of *(key, value)* pairs. Such pairs
are referred to as an *item* in the following.

# Convert

toMap :: Ord k => AList k v -> Map k v Source

`toMap`

converts to a `Map`

. Behavior with multiple keys is undefined.

# Query

lookupAll :: Eq k => k -> AList k v -> [v] Source

`lookupAll`

returns a `List`

of all items with the given key.

lookupFirst :: Eq k => k -> AList k v -> Maybe v Source

`lookupFirst`

finds the first value with a matching key, if there is one.

# Modify

deleteFirst :: Eq k => k -> AList k v -> AList k v Source

`deleteFirst`

deletes the first value with a given key.