map -package:daml-finance package:daml-stdlib
Apply a function over each element in the non-empty list.
`map f xs` applies the function `f` to all elements of the list `xs`
and returns the list of results (in the same order as `xs`).
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.
The `Map a b` type represents an associative array from keys of type `a`
to values of type `b`. It uses the built-in equality for keys. Import
`DA.Map` to use it.
Map each element of a structure to an action, evaluate these
actions from left to right, and ignore the results. For a version
that doesn't ignore the results see 'DA.Traversable.mapA'.
The `mapAccumL` function combines the behaviours of `map` and
`foldl`; it applies a function to each element of a list, passing
an accumulating parameter from left to right, and returning a final
value of this accumulator together with the new list.
The `mapOptional` function is a version of `map` which can throw out
elements. In particular, the functional argument returns something
of type `Optional b`. If this is `None`, no element is added on to
the result list. If it is `Some b`, then `b` is included in the
result list.
Map each element of a structure to an action, evaluate these actions
from left to right, and collect the results.
Apply an applicative function to each element of a list.
Map over both arguments at the same time.
```daml-force
bimap f g ≡ first f . second g
```
Examples:
```
>>> bimap not (+1) (True, 3)
(False,4)
>>> bimap not (+1) (Left True)
Left False
>>> bimap not (+1) (Right 3)
Right 4
```
Combine the elements of a structure using a monoid.
Create a `Set` from a `Map`.
Convert a `Set` into a `Map`.
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.
The `TextMap a` type represents an associative array from keys of type
`Text` to values of type `a`.
Map a function over each element of a list, and concatenate all the results.
`fmap` takes a function of type `a -> b`, and turns it into a
function of type `f a -> f b`, where `f` is the type which is an
instance of `Functor`.
For example, `map` is an `fmap` that only works on lists.
It takes a function `a -> b` and a `[a]`, and returns a `[b]`.