Module

Data.Lens.Fold

Package
purescript-profunctor-lenses
Repository
purescript-contrib/purescript-profunctor-lenses

This module defines functions for working with folds.

#(^?) Source

Operator alias for Data.Lens.Fold.previewOn (left-associative / precedence 8)

#previewOn Source

previewOn :: forall b a t s. s -> Fold (First a) s t a b -> Maybe a

Synonym for preview, flipped.

#(^..) Source

Operator alias for Data.Lens.Fold.toListOfOn (left-associative / precedence 8)

#toListOfOn Source

toListOfOn :: forall b a t s. s -> Fold (Endo Function (List a)) s t a b -> List a

Synonym for toListOf, reversed.

#preview Source

preview :: forall b a t s. Fold (First a) s t a b -> s -> Maybe a

Previews the first value of a fold, if there is any.

#foldOf Source

foldOf :: forall b a t s. Fold a s t a b -> s -> a

Folds all foci of a Fold to one. Note that this is the same as view.

#foldMapOf Source

foldMapOf :: forall r b a t s. Fold r s t a b -> (a -> r) -> s -> r

Maps and then folds all foci of a Fold.

#foldrOf Source

foldrOf :: forall r b a t s. Fold (Endo Function r) s t a b -> (a -> r -> r) -> r -> s -> r

Right fold over a Fold.

#foldlOf Source

foldlOf :: forall r b a t s. Fold (Dual (Endo Function r)) s t a b -> (r -> a -> r) -> r -> s -> r

Left fold over a Fold.

#toListOf Source

toListOf :: forall b a t s. Fold (Endo Function (List a)) s t a b -> s -> List a

Collects the foci of a Fold into a list.

#firstOf Source

firstOf :: forall b a t s. Fold (First a) s t a b -> s -> Maybe a

The first focus of a Fold, if there is any. Synonym for preview.

#lastOf Source

lastOf :: forall b a t s. Fold (Last a) s t a b -> s -> Maybe a

The last focus of a Fold, if there is any.

#maximumOf Source

maximumOf :: forall b a t s. Ord a => Fold (Endo Function (Maybe a)) s t a b -> s -> Maybe a

The maximum of all foci of a Fold, if there is any.

#minimumOf Source

minimumOf :: forall b a t s. Ord a => Fold (Endo Function (Maybe a)) s t a b -> s -> Maybe a

The minimum of all foci of a Fold, if there is any.

#allOf Source

allOf :: forall r b a t s. HeytingAlgebra r => Fold (Conj r) s t a b -> (a -> r) -> s -> r

Whether all foci of a Fold satisfy a predicate.

#anyOf Source

anyOf :: forall r b a t s. HeytingAlgebra r => Fold (Disj r) s t a b -> (a -> r) -> s -> r

Whether any focus of a Fold satisfies a predicate.

#andOf Source

andOf :: forall b a t s. HeytingAlgebra a => Fold (Conj a) s t a b -> s -> a

The conjunction of all foci of a Fold.

#orOf Source

orOf :: forall b a t s. HeytingAlgebra a => Fold (Disj a) s t a b -> s -> a

The disjunction of all foci of a Fold.

#elemOf Source

elemOf :: forall b a t s. Eq a => Fold (Disj Boolean) s t a b -> a -> s -> Boolean

Whether a Fold contains a given element.

#notElemOf Source

notElemOf :: forall b a t s. Eq a => Fold (Conj Boolean) s t a b -> a -> s -> Boolean

Whether a Fold not contains a given element.

#sumOf Source

sumOf :: forall b a t s. Semiring a => Fold (Additive a) s t a b -> s -> a

The sum of all foci of a Fold.

#productOf Source

productOf :: forall b a t s. Semiring a => Fold (Multiplicative a) s t a b -> s -> a

The product of all foci of a Fold.

#lengthOf Source

lengthOf :: forall b a t s. Fold (Additive Int) s t a b -> s -> Int

The number of foci of a Fold.

#findOf Source

findOf :: forall b a t s. Fold (Endo Function (Maybe a)) s t a b -> (a -> Boolean) -> s -> Maybe a

Find the first focus of a Fold that satisfies a predicate, if there is any.

#sequenceOf_ Source

sequenceOf_ :: forall b a t s f. Applicative f => Fold (Endo Function (f Unit)) s t (f a) b -> s -> f Unit

Sequence the foci of a Fold, pulling out an Applicative, and ignore the result. If you need the result, see sequenceOf for Traversals.

#traverseOf_ Source

traverseOf_ :: forall r b a t s f. Applicative f => Fold (Endo Function (f Unit)) s t a b -> (a -> f r) -> s -> f Unit

Traverse the foci of a Fold, discarding the results.

#has Source

has :: forall r b a t s. HeytingAlgebra r => Fold (Disj r) s t a b -> s -> r

Determines whether a Fold has at least one focus.

#hasn't Source

hasn't :: forall r b a t s. HeytingAlgebra r => Fold (Conj r) s t a b -> s -> r

Determines whether a Fold does not have a focus.

#replicated Source

replicated :: forall r t b a. Monoid r => Int -> Fold r a b a t

Replicates the elements of a fold.

#filtered Source

filtered :: forall a p. Choice p => (a -> Boolean) -> Optic' p a a

Filters on a predicate.

#folded Source

folded :: forall r t b a g. Monoid r => Foldable g => Fold r (g a) b a t

Folds over a Foldable container.

#unfolded Source

unfolded :: forall b a t s r. Monoid r => (s -> Maybe (Tuple a s)) -> Fold r s t a b

Builds a Fold using an unfold.

#ifoldMapOf Source

ifoldMapOf :: forall b a t s i r. IndexedFold r i s t a b -> (i -> a -> r) -> s -> r

Fold map over an IndexedFold.

#ifoldrOf Source

ifoldrOf :: forall r b a t s i. IndexedFold (Endo Function r) i s t a b -> (i -> a -> r -> r) -> r -> s -> r

Right fold over an IndexedFold.

#ifoldlOf Source

ifoldlOf :: forall r b a t s i. IndexedFold (Dual (Endo Function r)) i s t a b -> (i -> r -> a -> r) -> r -> s -> r

Left fold over an IndexedFold.

#iallOf Source

iallOf :: forall r b a t s i. HeytingAlgebra r => IndexedFold (Conj r) i s t a b -> (i -> a -> r) -> s -> r

Whether all foci of an IndexedFold satisfy a predicate.

#ianyOf Source

ianyOf :: forall r b a t s i. HeytingAlgebra r => IndexedFold (Disj r) i s t a b -> (i -> a -> r) -> s -> r

Whether any focus of an IndexedFold satisfies a predicate.

#itoListOf Source

itoListOf :: forall b a t s i. IndexedFold (Endo Function (List (Tuple i a))) i s t a b -> s -> List (Tuple i a)

Collects the foci of an IndexedFold into a list.

#itraverseOf_ Source

itraverseOf_ :: forall r b a t s f i. Applicative f => IndexedFold (Endo Function (f Unit)) i s t a b -> (i -> a -> f r) -> s -> f Unit

Traverse the foci of an IndexedFold, discarding the results.

Re-exports from Data.Lens.Types

#Fold' Source

type Fold' r s a = Fold r s s a a

#Fold Source

type Fold r s t a b = Optic (Forget r) s t a b

A fold.