Module

Data.Semigroup.Foldable

Package
foldable-traversable
Repository
purerl/purescript-foldable-traversable

#Foldable1 Source

class Foldable1 :: (Type -> Type) -> Constraintclass (Foldable t) <= Foldable1 t  where

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

  • foldr1 folds a structure from the right
  • foldl1 folds a structure from the left
  • foldMap1 folds a structure by accumulating values in a Semigroup

Default implementations are provided by the following functions:

  • foldr1Default
  • foldl1Default
  • foldMap1DefaultR
  • foldMap1DefaultL

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

  • foldr1 :: forall a. (a -> a -> a) -> t a -> a
  • foldl1 :: forall a. (a -> a -> a) -> t a -> a
  • foldMap1 :: forall a m. Semigroup m => (a -> m) -> t a -> m

Instances

#fold1 Source

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

Fold a data structure, accumulating values in some Semigroup.

#traverse1_ Source

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_ Source

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_ Source

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.

#foldr1Default Source

foldr1Default :: forall t a. Foldable1 t => (a -> a -> a) -> t a -> a

A default implementation of foldr1 using foldMap1.

Note: when defining a Foldable1 instance, this function is unsafe to use in combination with foldMap1DefaultR.

#foldl1Default Source

foldl1Default :: forall t a. Foldable1 t => (a -> a -> a) -> t a -> a

A default implementation of foldl1 using foldMap1.

Note: when defining a Foldable1 instance, this function is unsafe to use in combination with foldMap1DefaultL.

#foldMap1DefaultR Source

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

A default implementation of foldMap1 using foldr1.

Note: when defining a Foldable1 instance, this function is unsafe to use in combination with foldr1Default.

#foldMap1DefaultL Source

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

A default implementation of foldMap1 using foldl1.

Note: when defining a Foldable1 instance, this function is unsafe to use in combination with foldl1Default.

#foldMap1Default Source

foldMap1Default :: forall t m a. Warn (Text "\'foldMap1Default\' is deprecated, use \'foldMap1DefaultL\' instead") => Foldable1 t => Functor t => Semigroup m => (a -> m) -> t a -> m

Deprecated previous name of foldMap1DefaultL.

#intercalate Source

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 Source

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 Source

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

#maximumBy Source

maximumBy :: forall f a. Foldable1 f => (a -> a -> Ordering) -> f a -> a

#minimum Source

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

#minimumBy Source

minimumBy :: forall f a. Foldable1 f => (a -> a -> Ordering) -> f a -> a