# map -package:base -is:exact -is:exact -package:unordered-containers -package:bytestring -package:containers package:Cabal -is:module

map f xs is the list obtained by applying f to each element of xs, i.e.,
```map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
map f [x1, x2, ...] == [f x1, f x2, ...]
```
```>>> map (+1) [1, 2, 3]
```
A Map from keys k to values a. The Semigroup operation for Map is union, which prefers values from the left operand. If m1 maps a key k to a value a1, and m2 maps the same key to a different value a2, then their union m1 <> m2 maps k to a1.
The mapMaybe function is a version of map which can throw out elements. In particular, the functional argument returns something of type Maybe b. If this is Nothing, no element is added on to the result list. If it is Just b, then b is included in the result list.

#### Examples

Using mapMaybe f x is a shortcut for catMaybes \$ map f x in most cases:
```>>> import Text.Read ( readMaybe )

>>> mapMaybe readMaybeInt ["1", "Foo", "3"]
[1,3]

>>> catMaybes \$ map readMaybeInt ["1", "Foo", "3"]
[1,3]
```
If we map the Just constructor, the entire list should be returned:
```>>> mapMaybe Just [1,2,3]
[1,2,3]
```
An associative operation NOTE: This method is redundant and has the default implementation mappend = (<>) since base-4.11.0.0. Should it be implemented manually, since mappend is a synonym for (<>), it is expected that the two functions are defined the same way. In a future GHC release mappend will be removed from Monoid.
O(1). Convert a graph into a map from keys to nodes. The resulting map m is guaranteed to have the property that all ((k,n) -> k == nodeKey n) (toList m).
Map a function over all the elements of a container and concatenate the resulting lists.
Using ApplicativeDo: 'fmap f as' can be understood as the do expression
```do a <- as
pure (f a)
```
with an inferred Functor constraint.
Map each element of the structure to a monoid, and combine the results.
Generically generate a Semigroup (<>) operation for any type implementing Generic. This operation will append two values by point-wise appending their component fields. It is only defined for product types.
```gmappend a (gmappend b c) = gmappend (gmappend a b) c
```
A map from component name to all matching components. These coincide with componentGraph
A GHC version-dependent mapping of extensions to flags. This must be set to be able to make use of the ghcOptExtensions.
A map of dependencies. Newtyped since the default monoid instance is not appropriate. The monoid instance uses intersectVersionRanges.