gambler-0.1.0.0: Composable, streaming, and efficient left folds
Safe HaskellSafe-Inferred
LanguageGHC2021

Fold.Pure.Examples.Boring

Description

Folds of other types trivially lifted into Fold

Synopsis

Length

null :: Fold a Bool Source #

True if the input contains no inputs

General

magma :: (a -> a -> a) -> Fold a (Maybe a) Source #

Start with the first input, append each new input on the right with the given function

semigroup :: Semigroup a => Fold a (Maybe a) Source #

Append each new input on the right with (<>)

Endpoints

first :: Fold a (Maybe a) Source #

The first input

last :: Fold a (Maybe a) Source #

The last input

Extrema

maximum :: Ord a => Fold a (Maybe a) Source #

The greatest input

minimum :: Ord a => Fold a (Maybe a) Source #

The least input

maximumBy :: (a -> a -> Ordering) -> Fold a (Maybe a) Source #

The greatest input with respect to the given comparison function

minimumBy :: (a -> a -> Ordering) -> Fold a (Maybe a) Source #

The least input with respect to the given comparison function

Boolean

and :: Fold Bool Bool Source #

True if all inputs are True

or :: Fold Bool Bool Source #

True if any input is True

all :: (a -> Bool) -> Fold a Bool Source #

True if all inputs satisfy the predicate

any :: (a -> Bool) -> Fold a Bool Source #

True if any input satisfies the predicate

Search

element :: Eq a => a -> Fold a Bool Source #

True if any input is equal to the given value

notElement :: Eq a => a -> Fold a Bool Source #

False if any input is equal to the given value

find :: (a -> Bool) -> Fold a (Maybe a) Source #

The first input that satisfies the predicate, if any

lookup :: Eq a => a -> Fold (a, b) (Maybe b) Source #

The b from the first tuple where a equals the given value, if any

Index

index :: Natural -> Fold a (Maybe a) Source #

The nth input, where n=0 is the first input, if the index is in bounds

findIndex :: (a -> Bool) -> Fold a (Maybe Natural) Source #

The index of the first input that satisfies the predicate, if any

elementIndex :: Eq a => a -> Fold a (Maybe Natural) Source #

The index of the first input that matches the given value, if any