Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data NonemptyFold a b = forall x.NonemptyFold {}
- run :: NonemptyFold a b -> NonEmpty a -> b
- magma :: (a -> a -> a) -> NonemptyFold a a
- semigroup :: Semigroup a => NonemptyFold a a
- monoid :: Monoid a => NonemptyFold a a
- first :: NonemptyFold a a
- last :: NonemptyFold a a
- maximum :: Ord a => NonemptyFold a a
- minimum :: Ord a => NonemptyFold a a
- maximumBy :: (a -> a -> Ordering) -> NonemptyFold a a
- minimumBy :: (a -> a -> Ordering) -> NonemptyFold a a
- length :: NonemptyFold a Natural
- and :: NonemptyFold Bool Bool
- or :: NonemptyFold Bool Bool
- all :: (a -> Bool) -> NonemptyFold a Bool
- any :: (a -> Bool) -> NonemptyFold a Bool
- sum :: Num a => NonemptyFold a a
- product :: Num a => NonemptyFold a a
- mean :: Fractional a => NonemptyFold a a
- variance :: Fractional a => NonemptyFold a a
- standardDeviation :: Floating a => NonemptyFold a a
- element :: Eq a => a -> NonemptyFold a Bool
- notElement :: Eq a => a -> NonemptyFold a Bool
- find :: (a -> Bool) -> NonemptyFold a (Maybe a)
- lookup :: Eq a => a -> NonemptyFold (a, b) (Maybe b)
- index :: Natural -> NonemptyFold a (Maybe a)
- findIndex :: (a -> Bool) -> NonemptyFold a (Maybe Natural)
- elementIndex :: Eq a => a -> NonemptyFold a (Maybe Natural)
- list :: NonemptyFold a (NonEmpty a)
- reverseList :: NonemptyFold a (NonEmpty a)
- fold :: Fold a b -> NonemptyFold a b
- effectfulFold :: EffectfulFold Identity a b -> NonemptyFold a b
- shortcutFold :: ShortcutFold a b -> NonemptyFold a b
- shortcutNonemptyFold :: ShortcutNonemptyFold a b -> NonemptyFold a b
- duplicate :: NonemptyFold a b -> NonemptyFold a (Fold a b)
- premap :: (a -> b) -> NonemptyFold b r -> NonemptyFold a r
- nest :: Applicative f => NonemptyFold a b -> NonemptyFold (f a) (f b)
Type
data NonemptyFold a b Source #
Processes at least one input of type a
and results in a value of type b
forall x. NonemptyFold | |
Instances
Run
run :: NonemptyFold a b -> NonEmpty a -> b Source #
Fold a nonempty listlike container to a single summary result
Examples
General
magma :: (a -> a -> a) -> NonemptyFold a a Source #
Start with the first input, append each new input on the right with the given function
monoid :: Monoid a => NonemptyFold a a Source #
Start with mempty
, append each input on the right with (<>
)
Endpoints
first :: NonemptyFold a a Source #
The first input
last :: NonemptyFold a a Source #
The last input
Extrema
maximum :: Ord a => NonemptyFold a a Source #
The greatest input
minimum :: Ord a => NonemptyFold a a Source #
The least input
maximumBy :: (a -> a -> Ordering) -> NonemptyFold a a Source #
The greatest input with respect to the given comparison function
minimumBy :: (a -> a -> Ordering) -> NonemptyFold a a Source #
The least input with respect to the given comparison function
Length
length :: NonemptyFold a Natural Source #
The number of inputs
Boolean
Numeric
sum :: Num a => NonemptyFold a a Source #
Adds the inputs
product :: Num a => NonemptyFold a a Source #
Multiplies the inputs
mean :: Fractional a => NonemptyFold a a Source #
Numerically stable arithmetic mean of the inputs
variance :: Fractional a => NonemptyFold a a Source #
Numerically stable (population) variance over the inputs
standardDeviation :: Floating a => NonemptyFold a a Source #
Numerically stable (population) standard deviation over the inputs
Search
notElement :: Eq a => a -> NonemptyFold a Bool Source #
False
if any input is equal to the given value
find :: (a -> Bool) -> NonemptyFold a (Maybe a) Source #
The first input that satisfies the predicate, if any
lookup :: Eq a => a -> NonemptyFold (a, b) (Maybe b) Source #
The b
from the first tuple where a
equals the given value, if any
Index
index :: Natural -> NonemptyFold a (Maybe a) Source #
The nth input, where n=0 is the first input, if the index is in bounds
findIndex :: (a -> Bool) -> NonemptyFold a (Maybe Natural) Source #
The index of the first input that satisfies the predicate, if any
elementIndex :: Eq a => a -> NonemptyFold a (Maybe Natural) Source #
The index of the first input that matches the given value, if any
List
list :: NonemptyFold a (NonEmpty a) Source #
All the inputs
reverseList :: NonemptyFold a (NonEmpty a) Source #
All the inputs in reverse order
Conversion
fold :: Fold a b -> NonemptyFold a b Source #
Turn a regular fold that allows empty input into a fold that requires at least one input
effectfulFold :: EffectfulFold Identity a b -> NonemptyFold a b Source #
Turn an effectful fold into a pure fold that requires at least one input
shortcutFold :: ShortcutFold a b -> NonemptyFold a b Source #
shortcutNonemptyFold :: ShortcutNonemptyFold a b -> NonemptyFold a b Source #
Utilities
duplicate :: NonemptyFold a b -> NonemptyFold a (Fold a b) Source #
Allows to continue feeding a fold even after passing it to a function that closes it
premap :: (a -> b) -> NonemptyFold b r -> NonemptyFold a r Source #
(premap f folder)
returns a new fold where f
is applied at each step
nest :: Applicative f => NonemptyFold a b -> NonemptyFold (f a) (f b) Source #
Nest a fold in an applicative