Module

Data.Semigroup.Foldable

#Foldable1

class (Foldable t) <= Foldable1 t  where

Foldable1 represents data structures with a minimum of one element that can be folded.

  • fold1 folds a structure using a Semigroup instance
  • foldMap1 folds a structure by accumulating values in a Semigroup

Default implementations are provided by the following functions:

  • fold1Default
  • foldMap1Default

Note: some combinations of the default implementations are unsafe to use together - causing a non-terminating mutually recursive cycle. These combinations are documented per function.

Members

Instances

#traverse1_

traverse1_ :: forall t f a b. Foldable1 t => Apply f => (a -> f b) -> t a -> f Unit

Traverse a data structure, performing some effects encoded by an Apply instance at each value, ignoring the final result.

#for1_

for1_ :: forall t f a b. Foldable1 t => Apply f => t a -> (a -> f b) -> f Unit

A version of traverse1_ with its arguments flipped.

This can be useful when running an action written using do notation for every element in a data structure:

#sequence1_

sequence1_ :: forall t f a. Foldable1 t => Apply f => t (f a) -> f Unit

Perform all of the effects in some data structure in the order given by the Foldable1 instance, ignoring the final result.

#foldMap1Default

foldMap1Default :: forall t m a. Foldable1 t => Functor t => Semigroup m => (a -> m) -> t a -> m

A default implementation of foldMap1 using fold1.

#fold1Default

fold1Default :: forall t m. Foldable1 t => Semigroup m => t m -> m

A default implementation of fold1 using foldMap1.

#intercalate

intercalate :: forall f m. Foldable1 f => Semigroup m => m -> f m -> m

Fold a data structure using a Semigroup instance, combining adjacent elements using the specified separator.

#intercalateMap

intercalateMap :: forall f m a. Foldable1 f => Semigroup m => m -> (a -> m) -> f a -> m

Fold a data structure, accumulating values in some Semigroup, combining adjacent elements using the specified separator.

#maximum

maximum :: forall f a. Ord a => Foldable1 f => f a -> a

#minimum

minimum :: forall f a. Ord a => Foldable1 f => f a -> a

Modules