Package frege.control.Foldable

Compiled: Wed Dec 05 00:09:39 PST 2012 from source file: ./frege/control/Foldable.fr

Package Documentation

Contributed by Daniel Gronau

Table of Content

Imports

Classes

class Foldable t

Data structures that can be folded. Minimal complete definition: foldMap or foldr. Implementing foldl is recommended.

Known Instances

[], Maybe

Member Functions

fold :: (Foldable t, Monoid m) => t m -> m

Combine the elements of a structure using a monoid.

fold1 :: (Foldable t, Semigroup m) => t m -> m

A variant of fold that has no base case, and thus may only be applied to non-empty structures.

(not in Haskell's Foldable, because they have no Semigroup)

foldMap :: (Foldable t, Monoid m) => (a->m) -> t a -> m

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

foldMap1 :: (Foldable t, Semigroup m) => (a->m) -> t a -> m

A variant of foldMap that has no base case, and thus may only be applied to non-empty structures.

(not in Haskell's Foldable, because they have no Semigroup)

foldl :: Foldable t => (a->b->a) -> a -> t b -> a

Left-associative fold of a structure.

foldl1 :: Foldable t => (a->a->a) -> t a -> a

A variant of foldl that has no base case, and thus may only be applied to non-empty structures.

foldr :: Foldable t => (a->b->b) -> b -> t a -> b

Right-associative fold of a structure.

foldr1 :: Foldable t => (a->a->a) -> t a -> a

A variant of foldr that has no base case, and thus may only be applied to non-empty structures.

Instances

instance Foldable Maybe

Member Functions

fold :: Monoid α => Maybe α -> α

inherited from Foldable.fold

fold1 :: Semigroup α => Maybe α -> α

inherited from Foldable.fold1

foldMap :: Monoid β => (α->β) -> Maybe α -> β

inherited from Foldable.foldMap

foldMap1 :: Semigroup β => (α->β) -> Maybe α -> β

inherited from Foldable.foldMap1

foldl :: (α->β->α) -> α -> Maybe β -> α
foldl1 :: (α->α->α) -> Maybe α -> α

inherited from Foldable.foldl1

foldr :: (α->β->β) -> β -> Maybe α -> β
foldr1 :: (α->α->α) -> Maybe α -> α

inherited from Foldable.foldr1

instance Foldable []

Member Functions

fold :: Monoid α => [α] -> α

inherited from Foldable.fold

fold1 :: Semigroup α => [α] -> α

inherited from Foldable.fold1

foldMap :: Monoid β => (α->β) -> [α] -> β

inherited from Foldable.foldMap

foldMap1 :: Semigroup β => (α->β) -> [α] -> β

inherited from Foldable.foldMap1

foldl :: (α->β->α) -> α -> [β] -> α
foldl1 :: (α->α->α) -> [α] -> α

inherited from Foldable.foldl1

foldr :: (α->β->β) -> β -> [α] -> β
foldr1 :: (α->α->α) -> [α] -> α

inherited from Foldable.foldr1

Functions and Values

all :: Foldable t => (a->Bool) -> t a -> Bool

Determines whether all elements of the structure satisfy the predicate.

and :: Foldable t => t Bool -> Bool

and returns the conjunction of a container of Bools. For the result to be true, the container must be finite; false, however, results from a false value finitely far from the left end.

any :: Foldable t => (a->Bool) -> t a -> Bool

Determines whether any element of the structure satisfies the predicate.

concat :: Foldable t => t [a] -> [a]

The concatenation of all the elements of a container of lists.

concatMap :: Foldable t => (a->[b]) -> t a -> [b]

Map a function over all the elements of a container and concatenate the resulting lists.

elem :: (Foldable t, Eq a) => a -> t a -> Bool

Does the element occur in the structure?

find :: Foldable t => (a->Bool) -> t a -> Maybe a

The find function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or Maybe.Nothing if there is no such element.

foldMapa :: (Foldable t, Monoid m) => (a->m) -> t a -> m

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

folda :: (Foldable t, Monoid m) => t m -> m

Combine the elements of a structure using a monoid.

foldl' :: Foldable t => (a->b->a) -> a -> t b -> a

Fold over the elements of a structure, associating to the left, but strictly.

foldl1a :: Foldable t => (a->a->a) -> t a -> a

A variant of foldl that has no base case, and thus may only be applied to non-empty structures.

foldlM :: (Foldable t, Monad m) => (a->b->m a) -> a -> t b -> m a

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

foldr' :: Foldable t => (a->b->b) -> b -> t a -> b

Fold over the elements of a structure, associating to the right, but strictly.

foldr1a :: Foldable t => (a->a->a) -> t a -> a

A variant of foldr that has no base case, and thus may only be applied to non-empty structures.

foldrM :: (Foldable t, Monad m) => (a->b->m b) -> b -> t a -> m b

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

forM_ :: (Foldable t, Monad m) => t a -> (a->m b) -> m ()

forM_ is mapM_ with its arguments flipped.

for_ :: (Foldable t, Applicative f) => t a -> (a->f b) -> f ()

for_ is traverse_ with its arguments flipped.

mapM_ :: (Foldable t, Monad m) => (a->m b) -> t a -> m ()

Map each element of a structure to a monadic action, evaluate these actions from left to right, and ignore the results.

maximum :: (Foldable t, Ord a) => t a -> a

The largest element of a non-empty structure.

maximumBy :: Foldable t => (a->a->Ordering) -> t a -> a

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

minimum :: (Foldable t, Ord a) => t a -> a

The least element of a non-empty structure.

minimumBy :: Foldable t => (a->a->Ordering) -> t a -> a

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

msum :: (Foldable t, MonadPlus m) => t (m a) -> m a

The sum of a collection of actions, generalizing concat.

notElem :: (Foldable t, Eq a) => a -> t a -> Bool

notElem is the negation of elem.

or :: Foldable t => t Bool -> Bool

or returns the disjunction of a container of Bools. For the result to be false, the container must be finite; true, however, results from a true value finitely far from the left end.

product :: (Foldable t, Num a) => t a -> a

The product function computes the product of the numbers of a structure.

sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()

Evaluate each action in the structure from left to right, and ignore the results.

sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()

Evaluate each monadic action in the structure from left to right, and ignore the results.

sum :: (Foldable t, Num a) => t a -> a

The sum function computes the sum of the numbers of a structure.

traverse_ :: (Foldable t, Applicative f) => (a->f b) -> t a -> f ()

Map each element of a structure to an action, evaluate these actions from left to right, and ignore the results.

Functions and Values by Type

(α->α->α) -> Maybe α -> α

Foldable_Maybe.foldl1, Foldable_Maybe.foldr1

(α->α->α) -> [α] -> α

Foldable_[].foldl1, Foldable_[].foldr1

Foldable t => t Bool -> Bool

and, or

Monoid α => Maybe α -> α

Foldable_Maybe.fold

Monoid α => [α] -> α

Foldable_[].fold

Semigroup α => Maybe α -> α

Foldable_Maybe.fold1

Semigroup α => [α] -> α

Foldable_[].fold1

(α->β->α) -> α -> Maybe β -> α

Foldable_Maybe.foldl

(α->β->α) -> α -> [β] -> α

Foldable_[].foldl

(α->β->β) -> β -> Maybe α -> β

Foldable_Maybe.foldr

(α->β->β) -> β -> [α] -> β

Foldable_[].foldr

Foldable t => (a->a->Ordering) -> t a -> a

maximumBy, minimumBy

Foldable t => (a->a->a) -> t a -> a

foldl1a, foldr1a, Foldable.foldl1, Foldable.foldr1

Foldable t => (a->Bool) -> t a -> Maybe a

find

Foldable t => (a->Bool) -> t a -> Bool

all, any

Foldable t => t [a] -> [a]

concat

(Foldable t, Monoid m) => t m -> m

folda, Foldable.fold

(Foldable t, Semigroup m) => t m -> m

Foldable.fold1

(Foldable t, Eq a) => a -> t a -> Bool

elem, notElem

(Foldable t, Num a) => t a -> a

product, sum

(Foldable t, Ord a) => t a -> a

maximum, minimum

Monoid β => (α->β) -> Maybe α -> β

Foldable_Maybe.foldMap

Monoid β => (α->β) -> [α] -> β

Foldable_[].foldMap

Semigroup β => (α->β) -> Maybe α -> β

Foldable_Maybe.foldMap1

Semigroup β => (α->β) -> [α] -> β

Foldable_[].foldMap1

Foldable t => (a->b->a) -> a -> t b -> a

foldl', Foldable.foldl

Foldable t => (a->b->b) -> b -> t a -> b

foldr', Foldable.foldr

Foldable t => (a->[b]) -> t a -> [b]

concatMap

(Foldable t, Monoid m) => (a->m) -> t a -> m

foldMapa, Foldable.foldMap

(Foldable t, Semigroup m) => (a->m) -> t a -> m

Foldable.foldMap1

(Foldable t, Applicative f) => t (f a) -> f ()

sequenceA_

(Foldable t, Monad m) => t (m a) -> m ()

sequence_

(Foldable t, MonadPlus m) => t (m a) -> m a

msum

(Foldable t, Applicative f) => (a->f b) -> t a -> f ()

traverse_

(Foldable t, Applicative f) => t a -> (a->f b) -> f ()

for_

(Foldable t, Monad m) => (a->b->m a) -> a -> t b -> m a

foldlM

(Foldable t, Monad m) => (a->b->m b) -> b -> t a -> m b

foldrM

(Foldable t, Monad m) => (a->m b) -> t a -> m ()

mapM_

(Foldable t, Monad m) => t a -> (a->m b) -> m ()

forM_

Valid HTML 4.01 Strict