class (Foldable t) => Foldable1 (t :: Type -> Type)
Non-empty data structures that can be folded.
Instances define at least one of foldMap1 or foldrMap1.
fold1 :: (Semigroup m) => t m -> m
Given a structure with elements whose type is a Semigroup, combine
them via the semigroup's (<>) operator.
foldMap1 :: (Semigroup m) => (a -> m) -> t a -> m
Map each element of the structure to a semigroup, and combine the results.
toNonEmpty :: t a -> NonEmpty a
List of elements of a structure, from left to right.
intercalate1 :: (Foldable1 t, Semigroup m) => m -> t m -> m
Insert an m between each pair of t m.
foldrM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a
Monadic fold over the elements of a non-empty structure,
associating to the right.
foldlM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a
Monadic fold over the elements of a non-empty structure,
associating to the left.
intercalateMap1 :: (Foldable1 t, Semigroup m) => m -> (a -> m) -> t a -> m
Insert m between each pair of m derived from a.
>>> intercalateMap1 " " show $ True :| [False, True]
"True False True"
>>> intercalateMap1 " " show $ True :| []
"True"
traverse1_ :: (Foldable1 t, Apply f) => (a -> f b) -> t a -> f ()
for1_ :: (Foldable1 t, Apply f) => t a -> (a -> f b) -> f ()
sequenceA1_ :: (Foldable1 t, Apply f) => t (f a) -> f ()
foldMapDefault1 :: (Foldable1 t, Monoid m) => (a -> m) -> t a -> m
Usable default for foldMap, but only if you define foldMap1 yourself
asum1 :: (Foldable1 t, Alt m) => t (m a) -> m a
gfold1 :: (Foldable1 (Rep1 t), Generic1 t, Semigroup m) => t m -> m
Generic fold1. Caveats:
Will not compile if t is an empty constructor.
Will not compile if t has some fields that don't mention a, for example data Bar a = MkBar a Int
gfoldMap1 :: (Foldable1 (Rep1 t), Generic1 t, Semigroup m) => (a -> m) -> t a -> m
Generic foldMap1. Caveats are the same as for gfold1.
gtoNonEmpty :: (Foldable1 (Rep1 t), Generic1 t) => t a -> NonEmpty a
Generic toNonEmpty. Caveats are the same as for gfold1.
Instances
4
instance Semigroup a => Semigroup (JoinWith a)instance Apply f => Semigroup (Act f a)instance Functor f => Functor (Act f)instance Alt f => Semigroup (Alt_ f a)
- Maintainer
- Edward Kmett <ekmett@gmail.com>
- Portability
- portable
- Copyright
- (C) 2011-2015 Edward Kmett
- License
- BSD-style (see the file LICENSE)