Module

Data.Lens.Fold

Package
profunctor-lenses
Repository
purerl/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 s t a b. 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 s t a b. s -> Fold (Endo Function (List a)) s t a b -> List a

Synonym for toListOf, reversed.

#preview Source

preview :: forall s t a b. 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 s t a b. 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 s t a b r. Fold r s t a b -> (a -> r) -> s -> r

Maps and then folds all foci of a Fold.

#foldrOf Source

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

Right fold over a Fold.

#foldlOf Source

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

Left fold over a Fold.

#toListOf Source

toListOf :: forall s t a b. 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 s t a b. 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 s t a b. Fold (Last a) s t a b -> s -> Maybe a

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

#maximumOf Source

maximumOf :: forall s t a b. 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 s t a b. 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 s t a b r. 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 s t a b r. 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 s t a b. HeytingAlgebra a => Fold (Conj a) s t a b -> s -> a

The conjunction of all foci of a Fold.

#orOf Source

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

The disjunction of all foci of a Fold.

#elemOf Source

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

Whether a Fold contains a given element.

#notElemOf Source

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

Whether a Fold not contains a given element.

#sumOf Source

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

The sum of all foci of a Fold.

#productOf Source

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

The product of all foci of a Fold.

#lengthOf Source

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

The number of foci of a Fold.

#findOf Source

findOf :: forall s t a b. 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 f s t a b. 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 f s t a b r. 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 s t a b r. 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 s t a b r. HeytingAlgebra r => Fold (Conj r) s t a b -> s -> r

Determines whether a Fold does not have a focus.

#replicated Source

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

Replicates the elements of a fold.

#filtered Source

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

Filters on a predicate.

#folded Source

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

Folds over a Foldable container.

#unfolded Source

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

Builds a Fold using an unfold.

#toArrayOf Source

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

Collects the foci of a Fold into an array.

#toArrayOfOn Source

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

Synonym for toArrayOf, reversed.

#ifoldMapOf Source

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

Fold map over an IndexedFold.

#ifoldrOf Source

ifoldrOf :: forall i s t a b r. 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 i s t a b r. 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 i s t a b r. 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 i s t a b r. 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 i s t a b. 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 i f s t a b r. 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.