Copyright | Edward Kmett |
---|---|

License | BSD-style (see the LICENSE file in the distribution) |

Maintainer | libraries@haskell.org |

Stability | experimental |

Portability | portable |

Safe Haskell | Trustworthy |

Language | Haskell2010 |

class of non-empty data structures that can be folded to a summary value.

## Synopsis

- class Foldable t => Foldable1 t where
- fold1 :: Semigroup m => t m -> m
- foldMap1 :: Semigroup m => (a -> m) -> t a -> m
- foldMap1' :: Semigroup m => (a -> m) -> t a -> m
- foldr1 :: (a -> a -> a) -> t a -> a
- foldr1' :: (a -> a -> a) -> t a -> a
- foldl1 :: (a -> a -> a) -> t a -> a
- foldl1' :: (a -> a -> a) -> t a -> a
- toNonEmpty :: t a -> NonEmpty a
- maximum1 :: forall a. Ord a => t a -> a
- minimum1 :: forall a. Ord a => t a -> a
- head1 :: t a -> a
- last1 :: t a -> a
- foldrMap1 :: (a -> b) -> (a -> b -> b) -> t a -> b
- foldl'Map1 :: (a -> b) -> (b -> a -> b) -> t a -> b
- foldlMap1 :: (a -> b) -> (b -> a -> b) -> t a -> b
- foldr'Map1 :: (a -> b) -> (a -> b -> b) -> t a -> b

- intercalate1 :: (Foldable1 t, Semigroup m) => m -> t m -> m
- foldrM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a
- foldlM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a
- foldrMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (a -> b -> m b) -> t a -> m b
- foldlMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (b -> a -> m b) -> t a -> m b
- maximum1By :: Foldable1 t => (a -> a -> Ordering) -> t a -> a
- minimum1By :: Foldable1 t => (a -> a -> Ordering) -> t a -> a

# Documentation

class Foldable t => Foldable1 t where Source #

Non-empty data structures that can be folded.

fold1 :: Semigroup m => t m -> m Source #

Combine the elements of a structure using a semigroup.

foldMap1 :: Semigroup m => (a -> m) -> t a -> m Source #

Map each element of the structure to a semigroup, and combine the results.

`>>>`

Sum {getSum = 10}`foldMap1 Sum (1 :| [2, 3, 4])`

foldMap1' :: Semigroup m => (a -> m) -> t a -> m Source #

A variant of `foldMap1`

that is strict in the accumulator.

`>>>`

Sum {getSum = 10}`foldMap1' Sum (1 :| [2, 3, 4])`

foldr1 :: (a -> a -> a) -> t a -> a Source #

Right-associative fold of a structure.

In the case of lists, `foldr1`

, when applied to a binary operator,
and a list, reduces the list using the binary operator,
from right to left:

foldr1 f [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn1 `f` xn )...)

Note that, since the head of the resulting expression is produced by
an application of the operator to the first element of the list,
`foldr1`

can produce a terminating expression from an infinite list.

For a general `Foldable1`

structure this should be semantically identical
to,

`foldr1 f = foldr1 f . ``toNonEmpty`

foldr1' :: (a -> a -> a) -> t a -> a Source #

Right-associative fold of a structure, but with strict application of the operator.

foldl1 :: (a -> a -> a) -> t a -> a Source #

Left-associative fold of a structure.

In the case of lists, `foldl1`

, when applied to a binary
operator, and a list, reduces the list using the binary operator,
from left to right:

foldl1 f [x1, x2, ..., xn] == (...((x1 `f` x2) `f`...) `f` xn

Note that to produce the outermost application of the operator the
entire input list must be traversed. This means that `foldl1`

will
diverge if given an infinite list.

Also note that if you want an efficient left-fold, you probably want to
use `foldl1'`

instead of `foldl1`

. The reason for this is that latter does
not force the "inner" results (e.g. `x1 `f` x2`

in the above example)
before applying them to the operator (e.g. to `(`f` x3)`

). This results
in a thunk chain \(\mathcal{O}(n)\) elements long, which then must be
evaluated from the outside-in.

For a general `Foldable1`

structure this should be semantically identical
to,

`foldl1 f z = foldl1 f . ``toNonEmpty`

foldl1' :: (a -> a -> a) -> t a -> a Source #

Left-associative fold of a structure but with strict application of the operator.

This ensures that each step of the fold is forced to weak head normal
form before being applied, avoiding the collection of thunks that would
otherwise occur. This is often what you want to strictly reduce a finite
list to a single, monolithic result (e.g. `length`

).

For a general `Foldable1`

structure this should be semantically identical
to,

`foldl1' f z = foldl1 f . ``toNonEmpty`

toNonEmpty :: t a -> NonEmpty a Source #

List of elements of a structure, from left to right.

`>>>`

2 :| []`toNonEmpty (Identity 2)`

maximum1 :: forall a. Ord a => t a -> a Source #

The largest element of a non-empty structure.

`>>>`

128`maximum1 (32 :| [64, 8, 128, 16])`

minimum1 :: forall a. Ord a => t a -> a Source #

The least element of a non-empty structure.

`>>>`

8`minimum1 (32 :| [64, 8, 128, 16])`

The first element of a non-empty structure.

`>>>`

1`head1 (1 :| [2, 3, 4])`

The last element of a non-empty structure.

`>>>`

4`last1 (1 :| [2, 3, 4])`

foldrMap1 :: (a -> b) -> (a -> b -> b) -> t a -> b Source #

For `Functor`

s,

.`foldrMap1`

f g = foldr1 g . `fmap`

g

foldl'Map1 :: (a -> b) -> (b -> a -> b) -> t a -> b Source #

For `Functor`

s,

.`foldl'Map1`

f g = foldl1' g . `fmap`

g

foldlMap1 :: (a -> b) -> (b -> a -> b) -> t a -> b Source #

For `Functor`

s,

.`foldlMap1`

f g = foldl1 g . `fmap`

g

foldr'Map1 :: (a -> b) -> (a -> b -> b) -> t a -> b Source #

For `Functor`

s,

.`foldr'Map1`

f g = foldr1' g . `fmap`

g

## Instances

Foldable1 Par1 Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Par1 m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Par1 a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Par1 a -> m Source # foldr1 :: (a -> a -> a) -> Par1 a -> a Source # foldr1' :: (a -> a -> a) -> Par1 a -> a Source # foldl1 :: (a -> a -> a) -> Par1 a -> a Source # foldl1' :: (a -> a -> a) -> Par1 a -> a Source # toNonEmpty :: Par1 a -> NonEmpty a Source # maximum1 :: Ord a => Par1 a -> a Source # minimum1 :: Ord a => Par1 a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Par1 a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Par1 a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Par1 a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Par1 a -> b Source # | |

Foldable1 Complex Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Complex m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Complex a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Complex a -> m Source # foldr1 :: (a -> a -> a) -> Complex a -> a Source # foldr1' :: (a -> a -> a) -> Complex a -> a Source # foldl1 :: (a -> a -> a) -> Complex a -> a Source # foldl1' :: (a -> a -> a) -> Complex a -> a Source # toNonEmpty :: Complex a -> NonEmpty a Source # maximum1 :: Ord a => Complex a -> a Source # minimum1 :: Ord a => Complex a -> a Source # head1 :: Complex a -> a Source # last1 :: Complex a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Complex a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Complex a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Complex a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Complex a -> b Source # | |

Foldable1 Min Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Min m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Min a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Min a -> m Source # foldr1 :: (a -> a -> a) -> Min a -> a Source # foldr1' :: (a -> a -> a) -> Min a -> a Source # foldl1 :: (a -> a -> a) -> Min a -> a Source # foldl1' :: (a -> a -> a) -> Min a -> a Source # toNonEmpty :: Min a -> NonEmpty a Source # maximum1 :: Ord a => Min a -> a Source # minimum1 :: Ord a => Min a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Min a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Min a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Min a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Min a -> b Source # | |

Foldable1 Max Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Max m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Max a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Max a -> m Source # foldr1 :: (a -> a -> a) -> Max a -> a Source # foldr1' :: (a -> a -> a) -> Max a -> a Source # foldl1 :: (a -> a -> a) -> Max a -> a Source # foldl1' :: (a -> a -> a) -> Max a -> a Source # toNonEmpty :: Max a -> NonEmpty a Source # maximum1 :: Ord a => Max a -> a Source # minimum1 :: Ord a => Max a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Max a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Max a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Max a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Max a -> b Source # | |

Foldable1 First Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => First m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> First a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> First a -> m Source # foldr1 :: (a -> a -> a) -> First a -> a Source # foldr1' :: (a -> a -> a) -> First a -> a Source # foldl1 :: (a -> a -> a) -> First a -> a Source # foldl1' :: (a -> a -> a) -> First a -> a Source # toNonEmpty :: First a -> NonEmpty a Source # maximum1 :: Ord a => First a -> a Source # minimum1 :: Ord a => First a -> a Source # head1 :: First a -> a Source # last1 :: First a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> First a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> First a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> First a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> First a -> b Source # | |

Foldable1 Last Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Last m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Last a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Last a -> m Source # foldr1 :: (a -> a -> a) -> Last a -> a Source # foldr1' :: (a -> a -> a) -> Last a -> a Source # foldl1 :: (a -> a -> a) -> Last a -> a Source # foldl1' :: (a -> a -> a) -> Last a -> a Source # toNonEmpty :: Last a -> NonEmpty a Source # maximum1 :: Ord a => Last a -> a Source # minimum1 :: Ord a => Last a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Last a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Last a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Last a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Last a -> b Source # | |

Foldable1 Identity Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Identity m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Identity a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Identity a -> m Source # foldr1 :: (a -> a -> a) -> Identity a -> a Source # foldr1' :: (a -> a -> a) -> Identity a -> a Source # foldl1 :: (a -> a -> a) -> Identity a -> a Source # foldl1' :: (a -> a -> a) -> Identity a -> a Source # toNonEmpty :: Identity a -> NonEmpty a Source # maximum1 :: Ord a => Identity a -> a Source # minimum1 :: Ord a => Identity a -> a Source # head1 :: Identity a -> a Source # last1 :: Identity a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Identity a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Identity a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Identity a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Identity a -> b Source # | |

Foldable1 Dual Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Dual m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Dual a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Dual a -> m Source # foldr1 :: (a -> a -> a) -> Dual a -> a Source # foldr1' :: (a -> a -> a) -> Dual a -> a Source # foldl1 :: (a -> a -> a) -> Dual a -> a Source # foldl1' :: (a -> a -> a) -> Dual a -> a Source # toNonEmpty :: Dual a -> NonEmpty a Source # maximum1 :: Ord a => Dual a -> a Source # minimum1 :: Ord a => Dual a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Dual a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Dual a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Dual a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Dual a -> b Source # | |

Foldable1 Sum Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Sum m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Sum a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Sum a -> m Source # foldr1 :: (a -> a -> a) -> Sum a -> a Source # foldr1' :: (a -> a -> a) -> Sum a -> a Source # foldl1 :: (a -> a -> a) -> Sum a -> a Source # foldl1' :: (a -> a -> a) -> Sum a -> a Source # toNonEmpty :: Sum a -> NonEmpty a Source # maximum1 :: Ord a => Sum a -> a Source # minimum1 :: Ord a => Sum a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Sum a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Sum a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Sum a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Sum a -> b Source # | |

Foldable1 Product Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Product m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Product a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Product a -> m Source # foldr1 :: (a -> a -> a) -> Product a -> a Source # foldr1' :: (a -> a -> a) -> Product a -> a Source # foldl1 :: (a -> a -> a) -> Product a -> a Source # foldl1' :: (a -> a -> a) -> Product a -> a Source # toNonEmpty :: Product a -> NonEmpty a Source # maximum1 :: Ord a => Product a -> a Source # minimum1 :: Ord a => Product a -> a Source # head1 :: Product a -> a Source # last1 :: Product a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Product a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Product a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Product a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Product a -> b Source # | |

Foldable1 Down Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Down m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Down a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Down a -> m Source # foldr1 :: (a -> a -> a) -> Down a -> a Source # foldr1' :: (a -> a -> a) -> Down a -> a Source # foldl1 :: (a -> a -> a) -> Down a -> a Source # foldl1' :: (a -> a -> a) -> Down a -> a Source # toNonEmpty :: Down a -> NonEmpty a Source # maximum1 :: Ord a => Down a -> a Source # minimum1 :: Ord a => Down a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Down a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Down a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Down a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Down a -> b Source # | |

Foldable1 NonEmpty Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => NonEmpty m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> NonEmpty a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> NonEmpty a -> m Source # foldr1 :: (a -> a -> a) -> NonEmpty a -> a Source # foldr1' :: (a -> a -> a) -> NonEmpty a -> a Source # foldl1 :: (a -> a -> a) -> NonEmpty a -> a Source # foldl1' :: (a -> a -> a) -> NonEmpty a -> a Source # toNonEmpty :: NonEmpty a -> NonEmpty a Source # maximum1 :: Ord a => NonEmpty a -> a Source # minimum1 :: Ord a => NonEmpty a -> a Source # head1 :: NonEmpty a -> a Source # last1 :: NonEmpty a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> NonEmpty a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> NonEmpty a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> NonEmpty a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> NonEmpty a -> b Source # | |

Foldable1 Tree Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Tree m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Tree a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Tree a -> m Source # foldr1 :: (a -> a -> a) -> Tree a -> a Source # foldr1' :: (a -> a -> a) -> Tree a -> a Source # foldl1 :: (a -> a -> a) -> Tree a -> a Source # foldl1' :: (a -> a -> a) -> Tree a -> a Source # toNonEmpty :: Tree a -> NonEmpty a Source # maximum1 :: Ord a => Tree a -> a Source # minimum1 :: Ord a => Tree a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Tree a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Tree a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Tree a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Tree a -> b Source # | |

Foldable1 (V1 :: Type -> Type) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => V1 m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> V1 a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> V1 a -> m Source # foldr1 :: (a -> a -> a) -> V1 a -> a Source # foldr1' :: (a -> a -> a) -> V1 a -> a Source # foldl1 :: (a -> a -> a) -> V1 a -> a Source # foldl1' :: (a -> a -> a) -> V1 a -> a Source # toNonEmpty :: V1 a -> NonEmpty a Source # maximum1 :: Ord a => V1 a -> a Source # minimum1 :: Ord a => V1 a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> V1 a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> V1 a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> V1 a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> V1 a -> b Source # | |

Foldable1 ((,) a) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => (a, m) -> m Source # foldMap1 :: Semigroup m => (a0 -> m) -> (a, a0) -> m Source # foldMap1' :: Semigroup m => (a0 -> m) -> (a, a0) -> m Source # foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source # foldr1' :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source # foldl1' :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source # toNonEmpty :: (a, a0) -> NonEmpty a0 Source # maximum1 :: Ord a0 => (a, a0) -> a0 Source # minimum1 :: Ord a0 => (a, a0) -> a0 Source # head1 :: (a, a0) -> a0 Source # last1 :: (a, a0) -> a0 Source # foldrMap1 :: (a0 -> b) -> (a0 -> b -> b) -> (a, a0) -> b Source # foldl'Map1 :: (a0 -> b) -> (b -> a0 -> b) -> (a, a0) -> b Source # foldlMap1 :: (a0 -> b) -> (b -> a0 -> b) -> (a, a0) -> b Source # foldr'Map1 :: (a0 -> b) -> (a0 -> b -> b) -> (a, a0) -> b Source # | |

Foldable1 f => Foldable1 (Lift f) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Lift f m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Lift f a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Lift f a -> m Source # foldr1 :: (a -> a -> a) -> Lift f a -> a Source # foldr1' :: (a -> a -> a) -> Lift f a -> a Source # foldl1 :: (a -> a -> a) -> Lift f a -> a Source # foldl1' :: (a -> a -> a) -> Lift f a -> a Source # toNonEmpty :: Lift f a -> NonEmpty a Source # maximum1 :: Ord a => Lift f a -> a Source # minimum1 :: Ord a => Lift f a -> a Source # head1 :: Lift f a -> a Source # last1 :: Lift f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Lift f a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Lift f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Lift f a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Lift f a -> b Source # | |

Foldable1 f => Foldable1 (Rec1 f) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Rec1 f m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Rec1 f a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Rec1 f a -> m Source # foldr1 :: (a -> a -> a) -> Rec1 f a -> a Source # foldr1' :: (a -> a -> a) -> Rec1 f a -> a Source # foldl1 :: (a -> a -> a) -> Rec1 f a -> a Source # foldl1' :: (a -> a -> a) -> Rec1 f a -> a Source # toNonEmpty :: Rec1 f a -> NonEmpty a Source # maximum1 :: Ord a => Rec1 f a -> a Source # minimum1 :: Ord a => Rec1 f a -> a Source # head1 :: Rec1 f a -> a Source # last1 :: Rec1 f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Rec1 f a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Rec1 f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Rec1 f a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Rec1 f a -> b Source # | |

Foldable1 f => Foldable1 (Ap f) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Ap f m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Ap f a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Ap f a -> m Source # foldr1 :: (a -> a -> a) -> Ap f a -> a Source # foldr1' :: (a -> a -> a) -> Ap f a -> a Source # foldl1 :: (a -> a -> a) -> Ap f a -> a Source # foldl1' :: (a -> a -> a) -> Ap f a -> a Source # toNonEmpty :: Ap f a -> NonEmpty a Source # maximum1 :: Ord a => Ap f a -> a Source # minimum1 :: Ord a => Ap f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Ap f a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Ap f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Ap f a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Ap f a -> b Source # | |

Foldable1 f => Foldable1 (Alt f) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Alt f m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Alt f a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Alt f a -> m Source # foldr1 :: (a -> a -> a) -> Alt f a -> a Source # foldr1' :: (a -> a -> a) -> Alt f a -> a Source # foldl1 :: (a -> a -> a) -> Alt f a -> a Source # foldl1' :: (a -> a -> a) -> Alt f a -> a Source # toNonEmpty :: Alt f a -> NonEmpty a Source # maximum1 :: Ord a => Alt f a -> a Source # minimum1 :: Ord a => Alt f a -> a Source # head1 :: Alt f a -> a Source # last1 :: Alt f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Alt f a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Alt f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Alt f a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Alt f a -> b Source # | |

Foldable1 f => Foldable1 (Reverse f) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Reverse f m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Reverse f a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Reverse f a -> m Source # foldr1 :: (a -> a -> a) -> Reverse f a -> a Source # foldr1' :: (a -> a -> a) -> Reverse f a -> a Source # foldl1 :: (a -> a -> a) -> Reverse f a -> a Source # foldl1' :: (a -> a -> a) -> Reverse f a -> a Source # toNonEmpty :: Reverse f a -> NonEmpty a Source # maximum1 :: Ord a => Reverse f a -> a Source # minimum1 :: Ord a => Reverse f a -> a Source # head1 :: Reverse f a -> a Source # last1 :: Reverse f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Reverse f a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Reverse f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Reverse f a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Reverse f a -> b Source # | |

Foldable1 f => Foldable1 (IdentityT f) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => IdentityT f m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> IdentityT f a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> IdentityT f a -> m Source # foldr1 :: (a -> a -> a) -> IdentityT f a -> a Source # foldr1' :: (a -> a -> a) -> IdentityT f a -> a Source # foldl1 :: (a -> a -> a) -> IdentityT f a -> a Source # foldl1' :: (a -> a -> a) -> IdentityT f a -> a Source # toNonEmpty :: IdentityT f a -> NonEmpty a Source # maximum1 :: Ord a => IdentityT f a -> a Source # minimum1 :: Ord a => IdentityT f a -> a Source # head1 :: IdentityT f a -> a Source # last1 :: IdentityT f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> IdentityT f a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> IdentityT f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> IdentityT f a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> IdentityT f a -> b Source # | |

Foldable1 f => Foldable1 (Backwards f) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Backwards f m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Backwards f a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Backwards f a -> m Source # foldr1 :: (a -> a -> a) -> Backwards f a -> a Source # foldr1' :: (a -> a -> a) -> Backwards f a -> a Source # foldl1 :: (a -> a -> a) -> Backwards f a -> a Source # foldl1' :: (a -> a -> a) -> Backwards f a -> a Source # toNonEmpty :: Backwards f a -> NonEmpty a Source # maximum1 :: Ord a => Backwards f a -> a Source # minimum1 :: Ord a => Backwards f a -> a Source # head1 :: Backwards f a -> a Source # last1 :: Backwards f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Backwards f a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Backwards f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Backwards f a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Backwards f a -> b Source # | |

Foldable1 (Tagged b) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Tagged b m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Tagged b a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Tagged b a -> m Source # foldr1 :: (a -> a -> a) -> Tagged b a -> a Source # foldr1' :: (a -> a -> a) -> Tagged b a -> a Source # foldl1 :: (a -> a -> a) -> Tagged b a -> a Source # foldl1' :: (a -> a -> a) -> Tagged b a -> a Source # toNonEmpty :: Tagged b a -> NonEmpty a Source # maximum1 :: Ord a => Tagged b a -> a Source # minimum1 :: Ord a => Tagged b a -> a Source # head1 :: Tagged b a -> a Source # last1 :: Tagged b a -> a Source # foldrMap1 :: (a -> b0) -> (a -> b0 -> b0) -> Tagged b a -> b0 Source # foldl'Map1 :: (a -> b0) -> (b0 -> a -> b0) -> Tagged b a -> b0 Source # foldlMap1 :: (a -> b0) -> (b0 -> a -> b0) -> Tagged b a -> b0 Source # foldr'Map1 :: (a -> b0) -> (a -> b0 -> b0) -> Tagged b a -> b0 Source # | |

(Foldable1 f, Foldable1 g) => Foldable1 (f :+: g) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => (f :+: g) m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> (f :+: g) a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> (f :+: g) a -> m Source # foldr1 :: (a -> a -> a) -> (f :+: g) a -> a Source # foldr1' :: (a -> a -> a) -> (f :+: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :+: g) a -> a Source # foldl1' :: (a -> a -> a) -> (f :+: g) a -> a Source # toNonEmpty :: (f :+: g) a -> NonEmpty a Source # maximum1 :: Ord a => (f :+: g) a -> a Source # minimum1 :: Ord a => (f :+: g) a -> a Source # head1 :: (f :+: g) a -> a Source # last1 :: (f :+: g) a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> (f :+: g) a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> (f :+: g) a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> (f :+: g) a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> (f :+: g) a -> b Source # | |

(Foldable1 f, Foldable1 g) => Foldable1 (f :*: g) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => (f :*: g) m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> (f :*: g) a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> (f :*: g) a -> m Source # foldr1 :: (a -> a -> a) -> (f :*: g) a -> a Source # foldr1' :: (a -> a -> a) -> (f :*: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :*: g) a -> a Source # foldl1' :: (a -> a -> a) -> (f :*: g) a -> a Source # toNonEmpty :: (f :*: g) a -> NonEmpty a Source # maximum1 :: Ord a => (f :*: g) a -> a Source # minimum1 :: Ord a => (f :*: g) a -> a Source # head1 :: (f :*: g) a -> a Source # last1 :: (f :*: g) a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> (f :*: g) a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> (f :*: g) a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> (f :*: g) a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> (f :*: g) a -> b Source # | |

(Foldable1 f, Foldable1 g) => Foldable1 (Product f g) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Product f g m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Product f g a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Product f g a -> m Source # foldr1 :: (a -> a -> a) -> Product f g a -> a Source # foldr1' :: (a -> a -> a) -> Product f g a -> a Source # foldl1 :: (a -> a -> a) -> Product f g a -> a Source # foldl1' :: (a -> a -> a) -> Product f g a -> a Source # toNonEmpty :: Product f g a -> NonEmpty a Source # maximum1 :: Ord a => Product f g a -> a Source # minimum1 :: Ord a => Product f g a -> a Source # head1 :: Product f g a -> a Source # last1 :: Product f g a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Product f g a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Product f g a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Product f g a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Product f g a -> b Source # | |

(Foldable1 f, Foldable1 g) => Foldable1 (Sum f g) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Sum f g m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Sum f g a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Sum f g a -> m Source # foldr1 :: (a -> a -> a) -> Sum f g a -> a Source # foldr1' :: (a -> a -> a) -> Sum f g a -> a Source # foldl1 :: (a -> a -> a) -> Sum f g a -> a Source # foldl1' :: (a -> a -> a) -> Sum f g a -> a Source # toNonEmpty :: Sum f g a -> NonEmpty a Source # maximum1 :: Ord a => Sum f g a -> a Source # minimum1 :: Ord a => Sum f g a -> a Source # head1 :: Sum f g a -> a Source # last1 :: Sum f g a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Sum f g a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Sum f g a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Sum f g a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Sum f g a -> b Source # | |

Foldable1 f => Foldable1 (M1 i c f) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => M1 i c f m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> M1 i c f a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> M1 i c f a -> m Source # foldr1 :: (a -> a -> a) -> M1 i c f a -> a Source # foldr1' :: (a -> a -> a) -> M1 i c f a -> a Source # foldl1 :: (a -> a -> a) -> M1 i c f a -> a Source # foldl1' :: (a -> a -> a) -> M1 i c f a -> a Source # toNonEmpty :: M1 i c f a -> NonEmpty a Source # maximum1 :: Ord a => M1 i c f a -> a Source # minimum1 :: Ord a => M1 i c f a -> a Source # head1 :: M1 i c f a -> a Source # last1 :: M1 i c f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> M1 i c f a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> M1 i c f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> M1 i c f a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> M1 i c f a -> b Source # | |

(Foldable1 f, Foldable1 g) => Foldable1 (f :.: g) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => (f :.: g) m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> (f :.: g) a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> (f :.: g) a -> m Source # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a Source # foldr1' :: (a -> a -> a) -> (f :.: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a Source # foldl1' :: (a -> a -> a) -> (f :.: g) a -> a Source # toNonEmpty :: (f :.: g) a -> NonEmpty a Source # maximum1 :: Ord a => (f :.: g) a -> a Source # minimum1 :: Ord a => (f :.: g) a -> a Source # head1 :: (f :.: g) a -> a Source # last1 :: (f :.: g) a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> (f :.: g) a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> (f :.: g) a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> (f :.: g) a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> (f :.: g) a -> b Source # | |

(Foldable1 f, Foldable1 g) => Foldable1 (Compose f g) Source # | |

Defined in Data.Foldable1 fold1 :: Semigroup m => Compose f g m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Compose f g a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Compose f g a -> m Source # foldr1 :: (a -> a -> a) -> Compose f g a -> a Source # foldr1' :: (a -> a -> a) -> Compose f g a -> a Source # foldl1 :: (a -> a -> a) -> Compose f g a -> a Source # foldl1' :: (a -> a -> a) -> Compose f g a -> a Source # toNonEmpty :: Compose f g a -> NonEmpty a Source # maximum1 :: Ord a => Compose f g a -> a Source # minimum1 :: Ord a => Compose f g a -> a Source # head1 :: Compose f g a -> a Source # last1 :: Compose f g a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Compose f g a -> b Source # foldl'Map1 :: (a -> b) -> (b -> a -> b) -> Compose f g a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Compose f g a -> b Source # foldr'Map1 :: (a -> b) -> (a -> b -> b) -> Compose f g a -> b Source # |

intercalate1 :: (Foldable1 t, Semigroup m) => m -> t m -> m Source #

Insert an `m`

between each pair of `t m`

.

`>>>`

"hello, how, are, you"`intercalate1 ", " $ "hello" :| ["how", "are", "you"]`

`>>>`

"hello"`intercalate1 ", " $ "hello" :| []`

`>>>`

"IAmFineYou?"`intercalate1 mempty $ "I" :| ["Am", "Fine", "You?"]`

foldrM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a Source #

Monadic fold over the elements of a non-empty structure, associating to the right, i.e. from right to left.

foldlM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a Source #

Monadic fold over the elements of a non-empty structure, associating to the left, i.e. from left to right.

foldrMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (a -> b -> m b) -> t a -> m b Source #

Map variant of `foldrM1`

.

foldlMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (b -> a -> m b) -> t a -> m b Source #

Map variant of `foldlM1`

.

maximum1By :: Foldable1 t => (a -> a -> Ordering) -> t a -> a Source #

The largest element of a non-empty structure with respect to the given comparison function.

minimum1By :: Foldable1 t => (a -> a -> Ordering) -> t a -> a Source #

The least element of a non-empty structure with respect to the given comparison function.