Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data ShortcutFold a b = forall x y.ShortcutFold {
- initial :: Vitality x y
- step :: y -> a -> Vitality x y
- extractDead :: x -> b
- extractLive :: y -> b
- run :: ShortcutFold a b -> [a] -> b
- magma :: (a -> a -> a) -> ShortcutFold a (Maybe a)
- semigroup :: Semigroup a => ShortcutFold a (Maybe a)
- monoid :: Monoid a => ShortcutFold a a
- first :: ShortcutFold a (Maybe a)
- last :: ShortcutFold a (Maybe a)
- maximum :: Ord a => ShortcutFold a (Maybe a)
- minimum :: Ord a => ShortcutFold a (Maybe a)
- maximumBy :: (a -> a -> Ordering) -> ShortcutFold a (Maybe a)
- minimumBy :: (a -> a -> Ordering) -> ShortcutFold a (Maybe a)
- null :: ShortcutFold a Bool
- length :: ShortcutFold a Natural
- and :: ShortcutFold Bool Bool
- or :: ShortcutFold Bool Bool
- all :: (a -> Bool) -> ShortcutFold a Bool
- any :: (a -> Bool) -> ShortcutFold a Bool
- sum :: Num a => ShortcutFold a a
- product :: Num a => ShortcutFold a a
- mean :: Fractional a => ShortcutFold a a
- variance :: Fractional a => ShortcutFold a a
- standardDeviation :: Floating a => ShortcutFold a a
- element :: Eq a => a -> ShortcutFold a Bool
- notElement :: Eq a => a -> ShortcutFold a Bool
- find :: (a -> Bool) -> ShortcutFold a (Maybe a)
- lookup :: Eq a => a -> ShortcutFold (a, b) (Maybe b)
- index :: Natural -> ShortcutFold a (Maybe a)
- findIndex :: (a -> Bool) -> ShortcutFold a (Maybe Natural)
- elementIndex :: Eq a => a -> ShortcutFold a (Maybe Natural)
- list :: ShortcutFold a [a]
- reverseList :: ShortcutFold a [a]
- fold :: Fold a b -> ShortcutFold a b
- effectfulFold :: EffectfulFold Identity a b -> ShortcutFold a b
- nonemptyFold :: NonemptyFold a b -> ShortcutFold a (Maybe b)
- shortcutNonemptyFold :: ShortcutNonemptyFold a b -> ShortcutFold a (Maybe b)
- demotivate :: ShortcutFold a b -> ShortcutFold a b
Type
data ShortcutFold a b Source #
Processes inputs of type a
, has the ability to halt midway
through the stream, and results in a value of type b
forall x y. ShortcutFold | |
|
Instances
Run
run :: ShortcutFold a b -> [a] -> b Source #
Fold a listlike container to a single summary result, forcing only enough input to satisfy the short-cutting fold
Examples
General
magma :: (a -> a -> a) -> ShortcutFold a (Maybe a) Source #
Start with the first input, append each new input on the right with the given function (ambivalent)
semigroup :: Semigroup a => ShortcutFold a (Maybe a) Source #
Append each new input on the right with <>
(ambivalent)
monoid :: Monoid a => ShortcutFold a a Source #
Start with mempty
, append each input on the right with <>
(ambivalent)
Endpoints
first :: ShortcutFold a (Maybe a) Source #
The first input (tenacious)
last :: ShortcutFold a (Maybe a) Source #
The last input (ambivalent)
Extrema
maximumBy :: (a -> a -> Ordering) -> ShortcutFold a (Maybe a) Source #
The greatest input with respect to the given comparison function (ambivalent)
minimumBy :: (a -> a -> Ordering) -> ShortcutFold a (Maybe a) Source #
The least input with respect to the given comparison function (ambivalent)
Length
length :: ShortcutFold a Natural Source #
The number of inputs (ambivalent)
Boolean
all :: (a -> Bool) -> ShortcutFold a Bool Source #
True
if all inputs satisfy the predicate (tenacious)
any :: (a -> Bool) -> ShortcutFold a Bool Source #
True
if any input satisfies the predicate (tenacious)
Numeric
sum :: Num a => ShortcutFold a a Source #
Adds the inputs (ambivalent)
product :: Num a => ShortcutFold a a Source #
Multiplies the inputs (ambivalent)
mean :: Fractional a => ShortcutFold a a Source #
Numerically stable arithmetic mean of the inputs (ambivalent)
variance :: Fractional a => ShortcutFold a a Source #
Numerically stable (population) variance over the inputs (ambivalent)
standardDeviation :: Floating a => ShortcutFold a a Source #
Numerically stable (population) standard deviation over the inputs (ambivalent)
Search
element :: Eq a => a -> ShortcutFold a Bool Source #
True
if any input is equal to the given value (tenacious)
notElement :: Eq a => a -> ShortcutFold a Bool Source #
False
if any input is equal to the given value (tenacious)
find :: (a -> Bool) -> ShortcutFold a (Maybe a) Source #
The first input that satisfies the predicate, if any (tenacious)
lookup :: Eq a => a -> ShortcutFold (a, b) (Maybe b) Source #
The b
from the first tuple where a
equals the given value,
if any (tenacious)
Index
index :: Natural -> ShortcutFold a (Maybe a) Source #
The nth input, where n=0 is the first input, if the index is in bounds (tenacious)
findIndex :: (a -> Bool) -> ShortcutFold a (Maybe Natural) Source #
The index of the first input that satisfies the predicate, if any (tenacious)
elementIndex :: Eq a => a -> ShortcutFold a (Maybe Natural) Source #
The index of the first input that matches the given value, if any (tenacious)
List
list :: ShortcutFold a [a] Source #
All the inputs (ambivalent)
reverseList :: ShortcutFold a [a] Source #
All the inputs in reverse order (ambivalent)
Conversion
fold :: Fold a b -> ShortcutFold a b Source #
effectfulFold :: EffectfulFold Identity a b -> ShortcutFold a b Source #
nonemptyFold :: NonemptyFold a b -> ShortcutFold a (Maybe b) Source #
shortcutNonemptyFold :: ShortcutNonemptyFold a b -> ShortcutFold a (Maybe b) Source #
Utilities
demotivate :: ShortcutFold a b -> ShortcutFold a b Source #
Causes a shortcut fold to stop once it becomes ambivalent