concat package:base-compat

The concatenation of all the elements of a container of lists.

Examples

Basic usage:
>>> concat (Just [1, 2, 3])
[1,2,3]
>>> concat (Left 42)
[]
>>> concat [[1, 2, 3], [4, 5], [6], []]
[1,2,3,4,5,6]
Map a function over all the elements of a container and concatenate the resulting lists.

Examples

Basic usage:
>>> concatMap (take 3) [[1..], [10..], [100..], [1000..]]
[1,2,3,10,11,12,100,101,102,1000,1001,1002]
>>> concatMap (take 3) (Just [1..])
[1,2,3]
Fold a list using the monoid. For most types, the default definition for mconcat will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.
>>> mconcat ["Hello", " ", "Haskell", "!"]
"Hello Haskell!"
Reduce a non-empty list with <> The default definition should be sufficient, but this can be overridden for efficiency.
>>> import Data.List.NonEmpty (NonEmpty (..))

>>> sconcat $ "Hello" :| [" ", "Haskell", "!"]
"Hello Haskell!"