Module BoxMap

Non-linear ordered-map interface with data keys and non-linear values.

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

A non-linear ordered map interface.

  • .size — get the number of entries.
  • .keys — get the keys in map order.
  • .list — get all entries as (key) value pairs.
  • .get(key) — look up a key.
  • .put(key, value) — return a map with that entry inserted or updated.
  • .delete(key) — return a map with that entry removed.

Since BoxMap is non-linear, updates return another BoxMap value.

type BoxMap.Readonly<k, v> = box choice {
  .get => [k] Option<v>,
  .keys => List<k>,
  .list => List<(k) v>,
  .size => Nat,
}

A read-only view of a BoxMap.

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

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

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

Builds an empty BoxMap.