Module Map

Linear ordered-map interface with data keys.

type Map<k, v> = iterative choice {
  .entry => [k] (Option<v>) choice {
    .delete => self,
    .put => [v] self,
  },
  .keys => (List<k>) self,
  .list => List<(k) v>,
  .size => (Nat) self,
}

A linear ordered map interface.

  • .size — get the number of entries while keeping the map.
  • .keys — get the keys in map order while keeping the map.
  • .list — consume the map and return its entries as (key) value pairs.
  • .entry(key) — inspect the current Option<v> for key, then choose .put(value) or .delete.

The map is linear: .list consumes it, while .size, .keys, and .entry return a continuation for further use.

dec Map.FromList : [type v] <k: data>[List<(k) box v>] Map<k, v>

Builds a Map from (key) value pairs. If a key appears more than once, the last pair wins.

dec Map.New : [type k: data, type v] Map<k, v>

Builds an empty Map.