concat package:base

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]
Concatenate a list of lists.
>>> concat []
[]

>>> concat [[42]]
[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]
Map a function returning a list over a list and concatenate the results. concatMap can be seen as the composition of concat and map.
concatMap f xs == (concat . map f) xs
>>> concatMap (\i -> [-i,i]) []
[]

>>> concatMap (\i -> [-i,i]) [1,2,3]
[-1,1,-2,2,-3,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!"
Reduces a structure of lists to the concatenation of those lists.

Examples

Basic usage:
>>> biconcat ([1, 2, 3], [4, 5])
[1,2,3,4,5]
>>> biconcat (Left [1, 2, 3])
[1,2,3]
>>> biconcat (BiList [[1, 2, 3, 4, 5], [6, 7, 8]] [[9]])
[1,2,3,4,5,6,7,8,9]
Given a means of mapping the elements of a structure to lists, computes the concatenation of all such lists in order.

Examples

Basic usage:
>>> biconcatMap (take 3) (fmap digitToInt) ([1..], "89")
[1,2,3,8,9]
>>> biconcatMap (take 3) (fmap digitToInt) (Left [1..])
[1,2,3]
>>> biconcatMap (take 3) (fmap digitToInt) (Right "89")
[8,9]
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!"