espresso/ordered_map

Utility module for dealing with “OrderedMaps” which are lists of key/value pairs that are ordered by the key. It should have a similar interface to Map so you can swap them in and out, though not all the functions are implemented.

Since it is based on lists it will not be as efficient as maps but for our use case we only care about the ordering.

Types

pub type OrderedMap(a, b) =
  List(#(a, b))

Functions

pub fn fold(map: List(#(a, b)), initial: c, fun: fn(c, a, b) -> c) -> c
pub fn get(map: List(#(a, b)), key: a) -> Option(b)
pub fn insert(map: List(#(a, b)), key: a, value: b) -> List(
  #(a, b),
)
pub fn new() -> List(#(a, b))
pub fn update(map: List(#(a, b)), key: a, fun: fn(Option(b)) -> b) -> List(
  #(a, b),
)
Search Document