map package:daml-stdlib is:module
Note: This is only supported in Daml-LF 1.11 or later.
This module exports the generic map type `Map k v` and associated
functions. This module should be imported qualified, for example:
```
import DA.Map (Map)
import DA.Map qualified as M
```
This will give access to the `Map` type, and the various operations
as `M.lookup`, `M.insert`, `M.fromList`, etc.
`Map k v` internally uses the built-in order for the type `k`.
This means that keys that contain functions are not comparable
and will result in runtime errors. To prevent this, the `Ord k`
instance is required for most map operations. It is recommended to
only use `Map k v` for key types that have an `Ord k` instance
that is derived automatically using `deriving`:
```
data K = ...
deriving (Eq, Ord)
```
This includes all built-in types that aren't function types, such as
`Int`, `Text`, `Bool`, `(a, b)` assuming `a` and `b` have default
`Ord` instances, `Optional t` and `[t]` assuming `t` has a
default `Ord` instance, `Map k v` assuming `k` and `v` have
default `Ord` instances, and `Set k` assuming `k` has a
default `Ord` instance.
TextMap - A map is an associative array data type composed of a
collection of key/value pairs such that, each possible key appears
at most once in the collection.