Data.Map

lib/Data/Map.gob

No module comment.

type Map k v = BaseMap FoldHash k v

A hash map with the default hasher.

type BaseMap h k v

A map whose keys are hashed by h. h is the first parameter because it is the one fixed longest: a program picks a hasher once, and keys and values per map.

fun new : fun() -> BaseMap FoldHash a b

Returns an empty map with the default hasher.

fun withHasher : fun() -> BaseMap h k v

Returns an empty map whose keys h hashes, for the h the call site's type names.

fun put : [Hash k, Hasher h] fun(BaseMap h k v, k, v) -> Unit
fun get : [Hash k, Hasher h] fun(BaseMap h k v, k) -> Option v
fun delete : [Hash k, Hasher h] fun(BaseMap h k v, k) -> Bool
fun contains : [Hash k, Hasher h] fun(BaseMap h k v, k) -> Bool
fun getOr : [Hash k, Hasher h] fun(BaseMap h k v, k, v) -> v

The default is evaluated whether or not it is used: arguments are strict and left to right. A default that is expensive to build belongs behind a match on get.

fun update : [Hash k, Hasher h] fun(BaseMap h k v, k, v, fun(v) -> v) -> Unit

Read, modify, write, in one place. update(counts, word, 0, _ + 1) is the frequency count that is otherwise four lines and two lookups.

fun keys : fun(BaseMap h k v) -> Array k
fun values : fun(BaseMap h k v) -> Array v
fun entries : fun(BaseMap h k v) -> Array (k, v)
type MapCursor k v
instance Index (BaseMap h k v) : Hash k, Hasher h
instance SetIndex (BaseMap h k v) : Hash k, Hasher h
instance Eq (BaseMap h k v) : Hash k, Hasher h, Eq v

Equal when they hold the same keys with equal values, whatever order the keys went in and whatever either table's capacity or seed. Looks each of a's keys up in b, so it costs one lookup per entry.

instance Length (BaseMap h k v)
instance Iterator (BaseMap h k v)
instance Debug (BaseMap h k v) : Debug k, Debug v

Its entries in the order they were first put, {k: v, ...}. The table and the bucket chain are how it is stored, not what it holds.

instance Show (BaseMap h k v) : Debug k, Debug v

What its Debug prints: a container's text shows its elements' Debug, so that a string in it is quoted.