Simple, extensible Fold
s.
Uses an input a
to accumulate over b
.
wrap : (c -> a) -> Fold a b -> Fold c b
Apply a transformation to input of a Fold
.
custom : (b -> a -> b) -> Fold a b
Construct a Fold
that uses a
to accumulate over b
.
merge : Fold a b -> b -> a -> b
Evaluate your fold for a given accumulator and input.
list : Fold a (List a)
Cons an element onto the list.
string : Fold Char String
Cons a character onto the string.
arrayLeft : Fold a b -> Fold (Array a) b
Starting from the left, fold each element of the array onto 'b'.
arrayRight : Fold a b -> Fold (Array a) b
Starting from the right, fold each element of the array onto b
.
listLeft : Fold a b -> Fold (List a) b
Starting from the left, fold each element of the list onto b
.
listRight : Fold a b -> Fold (List a) b
Starting from the right, fold each element of the list onto 'b'.
maybe : Fold a b -> Fold (Maybe a) b
If the input is Just
, fold over it.
merge (maybe list) [ 2, 3 ] (Just 1) -- [ 1, 2, 3, 4 ]
merge (maybe string) "hello" Nothing -- "hello"
result : Fold a b -> Fold (Result e a) b
Fold a
onto b
if Result e a
is Ok
.
resultError : Fold e b -> Fold (Result e b) b
Fold 'e' onto 'b' if Result e a
is Err
.
stringLeft : Fold Char b -> Fold String b
Starting from the left, fold each character in the string onto b
.
stringRight : Fold Char b -> Fold String b
Starting from the right, fold each character in the string onto b
.
passed : Filter a -> Fold a b -> Fold a b
Apply a fold only if the filter passes.
failed : Filter a -> Fold a b -> Fold a b
Apply a fold only if the filter fails.