Copyright | Edward Kmett Oleg Grenrus |
---|---|
License | BSD-3-Clause |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
A class of non-empty data structures that can be folded to a summary value.
Since: base-4.18.0.0
Synopsis
- class Foldable t => Foldable1 (t :: Type -> Type) where
- fold1 :: Semigroup m => t m -> m
- foldMap1 :: Semigroup m => (a -> m) -> t a -> m
- foldMap1' :: Semigroup m => (a -> m) -> t a -> m
- toNonEmpty :: t a -> NonEmpty a
- maximum :: Ord a => t a -> a
- minimum :: Ord a => t a -> a
- head :: t a -> a
- last :: t a -> a
- foldrMap1 :: (a -> b) -> (a -> b -> b) -> t a -> b
- foldlMap1' :: (a -> b) -> (b -> a -> b) -> t a -> b
- foldlMap1 :: (a -> b) -> (b -> a -> b) -> t a -> b
- foldrMap1' :: (a -> b) -> (a -> b -> b) -> t a -> b
- foldr1 :: Foldable1 t => (a -> a -> a) -> t a -> a
- foldr1' :: Foldable1 t => (a -> a -> a) -> t a -> a
- foldl1 :: Foldable1 t => (a -> a -> a) -> t a -> a
- foldl1' :: Foldable1 t => (a -> a -> a) -> t a -> a
- 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
- maximumBy :: Foldable1 t => (a -> a -> Ordering) -> t a -> a
- minimumBy :: Foldable1 t => (a -> a -> Ordering) -> t a -> a
Documentation
class Foldable t => Foldable1 (t :: Type -> Type) where Source #
Non-empty data structures that can be folded.
Since: base-4.18.0.0
fold1 :: Semigroup m => t m -> m Source #
Given a structure with elements whose type is a Semigroup
, combine
them via the semigroup's (
operator. This fold is
right-associative and lazy in the accumulator. When you need a strict
left-associative fold, use <>
)foldMap1'
instead, with id
as the map.
Since: base-4.18.0.0
foldMap1 :: Semigroup m => (a -> m) -> t a -> m Source #
Map each element of the structure to a semigroup, and combine the
results with (
. This fold is right-associative and lazy in the
accumulator. For strict left-associative folds consider <>
)foldMap1'
instead.
>>>
foldMap1 (:[]) (1 :| [2, 3, 4])
[1,2,3,4]
Since: base-4.18.0.0
foldMap1' :: Semigroup m => (a -> m) -> t a -> m Source #
A left-associative variant of foldMap1
that is strict in the
accumulator. Use this for strict reduction when partial results are
merged via (
.<>
)
>>>
foldMap1' Sum (1 :| [2, 3, 4])
Sum {getSum = 10}
Since: base-4.18.0.0
toNonEmpty :: t a -> NonEmpty a Source #
NonEmpty
list of elements of a structure, from left to right.
>>>
toNonEmpty (Identity 2)
2 :| []
Since: base-4.18.0.0
maximum :: Ord a => t a -> a Source #
The largest element of a non-empty structure.
>>>
maximum (32 :| [64, 8, 128, 16])
128
Since: base-4.18.0.0
minimum :: Ord a => t a -> a Source #
The least element of a non-empty structure.
>>>
minimum (32 :| [64, 8, 128, 16])
8
Since: base-4.18.0.0
The first element of a non-empty structure.
>>>
head (1 :| [2, 3, 4])
1
Since: base-4.18.0.0
The last element of a non-empty structure.
>>>
last (1 :| [2, 3, 4])
4
Since: base-4.18.0.0
foldrMap1 :: (a -> b) -> (a -> b -> b) -> t a -> b Source #
Right-associative fold of a structure, lazy in the accumulator.
In case of NonEmpty
lists, foldrMap1
, when given a function f
, a
binary operator g
, and a list, reduces the list using g
from right to
left applying f
to the rightmost element:
foldrMap1 f g (x1 :| [x2, ..., xn1, xn]) == x1 `g` (x2 `g` ... (xn1 `g` (f xn))...)
Note that since the head of the resulting expression is produced by
an application of g
to the first element of the list, if g
is lazy
in its right argument, foldrMap1
can produce a terminating expression
from an unbounded list.
For a general Foldable1
structure this should be semantically identical
to:
foldrMap1 f g = foldrMap1 f g . toNonEmpty
Since: base-4.18.0.0
foldlMap1' :: (a -> b) -> (b -> a -> b) -> t a -> b 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 structure to a single strict result.
For a general Foldable1
structure this should be semantically identical
to:
foldlMap1' f z = foldlMap1' f z . toNonEmpty
Since: base-4.18.0.0
foldlMap1 :: (a -> b) -> (b -> a -> b) -> t a -> b Source #
Left-associative fold of a structure, lazy in the accumulator. This is rarely what you want, but can work well for structures with efficient right-to-left sequencing and an operator that is lazy in its left argument.
In case of NonEmpty
lists, foldlMap1
, when given a function f
, a
binary operator g
, and a list, reduces the list using g
from left to
right applying f
to the leftmost element:
foldlMap1 f g (x1 :| [x2, ..., xn]) == (...(((f x1) `g` x2) `g`...) `g` xn
Note that to produce the outermost application of the operator the entire
input list must be traversed. This means that foldlMap1
will diverge if
given an infinite list.
If you want an efficient strict left-fold, you probably want to use
foldlMap1'
instead of foldlMap1
. The reason for this is that the
latter does not force the inner results (e.g. (f x1) `g` x2
in the
above example) before applying them to the operator (e.g. to
(`g` x3)
). This results in a thunk chain \(O(n)\) elements long,
which then must be evaluated from the outside-in.
For a general Foldable1
structure this should be semantically identical
to:
foldlMap1 f g = foldlMap1 f g . toNonEmpty
Since: base-4.18.0.0
foldrMap1' :: (a -> b) -> (a -> b -> b) -> t a -> b Source #
foldrMap1'
is a variant of foldrMap1
that performs strict reduction
from right to left, i.e. starting with the right-most element. The input
structure must be finite, otherwise foldrMap1'
runs out of space
(diverges).
If you want a strict right fold in constant space, you need a structure that supports faster than \(O(n)\) access to the right-most element.
This method does not run in constant space for structures such as
NonEmpty
lists that don't support efficient right-to-left iteration and
so require \(O(n)\) space to perform right-to-left reduction. Use of this
method with such a structure is a hint that the chosen structure may be a
poor fit for the task at hand. If the order in which the elements are
combined is not important, use foldlMap1'
instead.
Since: base-4.18.0.0
Instances
Foldable1 Complex Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Complex a -> NonEmpty a Source # maximum :: Ord a => Complex a -> a Source # minimum :: Ord a => Complex a -> a Source # head :: Complex a -> a Source # last :: Complex a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Complex a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Complex a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Complex a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Complex a -> b Source # | |
Foldable1 Identity Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Identity a -> NonEmpty a Source # maximum :: Ord a => Identity a -> a Source # minimum :: Ord a => Identity a -> a Source # head :: Identity a -> a Source # last :: Identity a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Identity a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Identity a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Identity a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Identity a -> b Source # | |
Foldable1 Down Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Down a -> NonEmpty a Source # maximum :: Ord a => Down a -> a Source # minimum :: Ord a => Down a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Down a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Down a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Down a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Down a -> b Source # | |
Foldable1 First Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: First a -> NonEmpty a Source # maximum :: Ord a => First a -> a Source # minimum :: Ord a => First a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> First a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> First a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> First a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> First a -> b Source # | |
Foldable1 Last Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Last a -> NonEmpty a Source # maximum :: Ord a => Last a -> a Source # minimum :: Ord a => Last a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Last a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Last a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Last a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Last a -> b Source # | |
Foldable1 Max Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Max a -> NonEmpty a Source # maximum :: Ord a => Max a -> a Source # minimum :: Ord a => Max a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Max a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Max a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Max a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Max a -> b Source # | |
Foldable1 Min Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Min a -> NonEmpty a Source # maximum :: Ord a => Min a -> a Source # minimum :: Ord a => Min a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Min a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Min a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Min a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Min a -> b Source # | |
Foldable1 Dual Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Dual a -> NonEmpty a Source # maximum :: Ord a => Dual a -> a Source # minimum :: Ord a => Dual a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Dual a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Dual a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Dual a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Dual a -> b Source # | |
Foldable1 Product Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Product a -> NonEmpty a Source # maximum :: Ord a => Product a -> a Source # minimum :: Ord a => Product a -> a Source # head :: Product a -> a Source # last :: Product a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Product a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Product a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Product a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Product a -> b Source # | |
Foldable1 Sum Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Sum a -> NonEmpty a Source # maximum :: Ord a => Sum a -> a Source # minimum :: Ord a => Sum a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Sum a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Sum a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Sum a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Sum a -> b Source # | |
Foldable1 NonEmpty Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: NonEmpty a -> NonEmpty a Source # maximum :: Ord a => NonEmpty a -> a Source # minimum :: Ord a => NonEmpty a -> a Source # head :: NonEmpty a -> a Source # last :: NonEmpty a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> NonEmpty a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> NonEmpty a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> NonEmpty a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> NonEmpty a -> b Source # | |
Foldable1 Par1 Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Par1 a -> NonEmpty a Source # maximum :: Ord a => Par1 a -> a Source # minimum :: Ord a => Par1 a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Par1 a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Par1 a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Par1 a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Par1 a -> b Source # | |
Foldable1 Solo Source # | Since: base-4.18.0.0 |
Defined in Data.Foldable1 fold1 :: Semigroup m => Solo m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Solo a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Solo a -> m Source # toNonEmpty :: Solo a -> NonEmpty a Source # maximum :: Ord a => Solo a -> a Source # minimum :: Ord a => Solo a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Solo a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Solo a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Solo a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Solo a -> b Source # | |
Foldable1 (V1 :: Type -> Type) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: V1 a -> NonEmpty a Source # maximum :: Ord a => V1 a -> a Source # minimum :: Ord a => V1 a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> V1 a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> V1 a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> V1 a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> V1 a -> b Source # | |
Foldable1 ((,) a) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: (a, a0) -> NonEmpty a0 Source # maximum :: Ord a0 => (a, a0) -> a0 Source # minimum :: Ord a0 => (a, a0) -> a0 Source # head :: (a, a0) -> a0 Source # last :: (a, a0) -> a0 Source # foldrMap1 :: (a0 -> b) -> (a0 -> b -> b) -> (a, a0) -> b Source # foldlMap1' :: (a0 -> b) -> (b -> a0 -> b) -> (a, a0) -> b Source # foldlMap1 :: (a0 -> b) -> (b -> a0 -> b) -> (a, a0) -> b Source # foldrMap1' :: (a0 -> b) -> (a0 -> b -> b) -> (a, a0) -> b Source # | |
Foldable1 f => Foldable1 (Ap f) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Ap f a -> NonEmpty a Source # maximum :: Ord a => Ap f a -> a Source # minimum :: Ord a => Ap f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Ap f a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Ap f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Ap f a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Ap f a -> b Source # | |
Foldable1 f => Foldable1 (Alt f) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Alt f a -> NonEmpty a Source # maximum :: Ord a => Alt f a -> a Source # minimum :: Ord a => Alt f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Alt f a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Alt f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Alt f a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Alt f a -> b Source # | |
Foldable1 f => Foldable1 (Rec1 f) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Rec1 f a -> NonEmpty a Source # maximum :: Ord a => Rec1 f a -> a Source # minimum :: Ord a => Rec1 f a -> a Source # head :: Rec1 f a -> a Source # last :: Rec1 f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Rec1 f a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Rec1 f a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Rec1 f a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Rec1 f a -> b Source # | |
(Foldable1 f, Foldable1 g) => Foldable1 (Product f g) Source # | It would be enough for either half of a product to be |
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 # toNonEmpty :: Product f g a -> NonEmpty a Source # maximum :: Ord a => Product f g a -> a Source # minimum :: Ord a => Product f g a -> a Source # head :: Product f g a -> a Source # last :: Product f g a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Product f g a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Product f g a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Product f g a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Product f g a -> b Source # | |
(Foldable1 f, Foldable1 g) => Foldable1 (Sum f g) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Sum f g a -> NonEmpty a Source # maximum :: Ord a => Sum f g a -> a Source # minimum :: Ord a => Sum f g a -> a Source # head :: Sum f g a -> a Source # last :: Sum f g a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Sum f g a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Sum f g a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Sum f g a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Sum f g a -> b Source # | |
(Foldable1 f, Foldable1 g) => Foldable1 (f :*: g) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: (f :*: g) a -> NonEmpty a Source # maximum :: Ord a => (f :*: g) a -> a Source # minimum :: Ord a => (f :*: g) a -> a Source # head :: (f :*: g) a -> a Source # last :: (f :*: g) a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> (f :*: g) a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> (f :*: g) a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> (f :*: g) a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> (f :*: g) a -> b Source # | |
(Foldable1 f, Foldable1 g) => Foldable1 (f :+: g) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: (f :+: g) a -> NonEmpty a Source # maximum :: Ord a => (f :+: g) a -> a Source # minimum :: Ord a => (f :+: g) a -> a Source # head :: (f :+: g) a -> a Source # last :: (f :+: g) a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> (f :+: g) a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> (f :+: g) a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> (f :+: g) a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> (f :+: g) a -> b Source # | |
(Foldable1 f, Foldable1 g) => Foldable1 (Compose f g) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: Compose f g a -> NonEmpty a Source # maximum :: Ord a => Compose f g a -> a Source # minimum :: Ord a => Compose f g a -> a Source # head :: Compose f g a -> a Source # last :: Compose f g a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Compose f g a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Compose f g a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Compose f g a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Compose f g a -> b Source # | |
(Foldable1 f, Foldable1 g) => Foldable1 (f :.: g) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: (f :.: g) a -> NonEmpty a Source # maximum :: Ord a => (f :.: g) a -> a Source # minimum :: Ord a => (f :.: g) a -> a Source # head :: (f :.: g) a -> a Source # last :: (f :.: g) a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> (f :.: g) a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> (f :.: g) a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> (f :.: g) a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> (f :.: g) a -> b Source # | |
Foldable1 f => Foldable1 (M1 i c f) Source # | Since: base-4.18.0.0 |
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 # toNonEmpty :: M1 i c f a -> NonEmpty a Source # maximum :: Ord a => M1 i c f a -> a Source # minimum :: Ord a => M1 i c f a -> a Source # head :: M1 i c f a -> a Source # last :: M1 i c f a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> M1 i c f a -> b Source # foldlMap1' :: (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 # foldrMap1' :: (a -> b) -> (a -> b -> b) -> M1 i c f a -> b Source # |
foldr1 :: Foldable1 t => (a -> a -> a) -> t a -> a Source #
A variant of foldrMap1
where the rightmost element maps to itself.
Since: base-4.18.0.0
foldr1' :: Foldable1 t => (a -> a -> a) -> t a -> a Source #
A variant of foldrMap1'
where the rightmost element maps to itself.
Since: base-4.18.0.0
foldl1 :: Foldable1 t => (a -> a -> a) -> t a -> a Source #
A variant of foldlMap1
where the leftmost element maps to itself.
Since: base-4.18.0.0
foldl1' :: Foldable1 t => (a -> a -> a) -> t a -> a Source #
A variant of foldlMap1'
where the leftmost element maps to itself.
Since: base-4.18.0.0
intercalate1 :: (Foldable1 t, Semigroup m) => m -> t m -> m Source #
Insert an m
between each pair of t m
.
>>>
intercalate1 ", " $ "hello" :| ["how", "are", "you"]
"hello, how, are, you"
>>>
intercalate1 ", " $ "hello" :| []
"hello"
>>>
intercalate1 mempty $ "I" :| ["Am", "Fine", "You?"]
"IAmFineYou?"
Since: base-4.18.0.0
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.
Since: base-4.18.0.0
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.
Since: base-4.18.0.0
foldrMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (a -> b -> m b) -> t a -> m b Source #
Map variant of foldrM1
.
Since: base-4.18.0.0
foldlMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (b -> a -> m b) -> t a -> m b Source #
Map variant of foldlM1
.
Since: base-4.18.0.0