map

Map a function over a NonEmpty stream.
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, ...]
Transform the original string-like value but keep it case insensitive.
O(n) Transform this map by applying a function to every value.
O(n) Transform this set by applying a function to every value. The resulting set may be smaller than the source.
Transform the properties of some Node. This has no effect on TextNodes or Potatoes.
Transform the properties of some Node. This has no effect on TextNodes or Potatoes.
Like forLens but with the lambda as the first argument.
Change the type of a StateVar
Map both the return value and final state of a computation using the given function.
Same as fmap. Provided for the consistency with ToJSONKeyFunction.
maps an IO-performing function over any Traversable data type, performing all the IO actions concurrently, and returning the original data structure with the arguments replaced by the results. If any of the actions throw an exception, then all other actions are cancelled and the exception is re-thrown. For example, mapConcurrently works with lists:
pages <- mapConcurrently getURL ["url1", "url2", "url3"]
mapConcurrently_ is mapConcurrently with the return value discarded, just like mapM_.
An associative operation NOTE: This method is redundant and has the default implementation mappend = '(<>)' since base-4.11.0.0.
The mapAccumL function behaves like a combination of fmap and foldl; it applies a function to each element of a structure, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new structure.
The mapAccumR function behaves like a combination of fmap and foldr; it applies a function to each element of a structure, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new structure.
The mapAndUnzipM function maps its first argument over a list, returning the result as a pair of lists. This function is mainly used with complicated data structures or a state-transforming monad.
This function maps one exception into another as proposed in the paper "A semantics for imprecise exceptions".
Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see mapM_.
Map each element of a structure to a monadic action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see mapM. As of base 4.8.0.0, mapM_ is just traverse_, specialized to Monad.
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 )

>>> let readMaybeInt = readMaybe :: String -> Maybe Int

>>> 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]
The mapBoth function takes two functions and applies the first if iff the value takes the form Left _ and the second if the value takes the form Right _. Using Data.Bifunctor:
mapBoth = bimap
Using Control.Arrow:
mapBoth = (+++)
>>> mapBoth (*2) (*3) (Left 4)
Left 8
>>> mapBoth (*2) (*3) (Right 4)
Right 12
The mapLeft function takes a function and applies it to an Either value iff the value takes the form Left _. Using Data.Bifunctor:
mapLeft = first
Using Control.Arrow:
mapLeft = (left)
Using Control.Lens:
mapLeft = over _Left
>>> mapLeft (*2) (Left 4)
Left 8
>>> mapLeft (*2) (Right "hello")
Right "hello"