NonEmptyReducible
public protocol NonEmptyReducible : Reducible
NonEmptyReducible defines a Reducible
in terms of another type that has an instance of Foldable
and a method that is able to split a structure of values in a first value and the rest of the values in the structure.
-
Undocumented
Declaration
Swift
associatedtype G : Foldable
-
Divides a structure of values into a tuple that represents the first value of the structure (first component of the tuple) and the rest of values of the structure (second component of the tuple)
Parameters
fa
Structure of values.
Return Value
Tuple containing the first and rest of values in the structure.
-
foldLeft(_:_:_:)
Extension methodDeclaration
Swift
static func foldLeft<A, B>( _ fa: Kind<Self, A>, _ b: B, _ f: @escaping (B, A) -> B) -> B
-
foldRight(_:_:_:)
Extension method -
reduceLeftTo(_:_:_:)
Extension methodDeclaration
Swift
static func reduceLeftTo<A, B>( _ fa: Kind<Self, A>, _ f: (A) -> B, _ g: @escaping (B, A) -> B) -> B
-
reduceRightTo(_:_:_:)
Extension method -
fold(_:)
Extension methodFolds a structure of values provided that its type has an instance of
Monoid
.It uses the monoid empty value as initial value and the combination method for the fold.
Parameters
fa
Value to be folded.
Return Value
Summary value resulting from the folding process.
-
find(_:_:)
Extension methodLooks for an element that matches a given predicate.
Declaration
Parameters
fa
Structure of values where the element matching the predicate needs to be found.
f
Predicate.
Return Value
A value if there is any that matches the predicate, or
Option.none
. -
exists(_:_:)
Extension methodChecks if any element in a structure matches a given predicate.
Declaration
Swift
static func exists<A>( _ fa: Kind<Self, A>, _ predicate: @escaping (A) -> Bool) -> Bool
Parameters
fa
Structure of values where the element matching the predicate needs to be found.
predicate
Predicate.
Return Value
A boolean value indicating if any elements in the structure match the predicate.
-
forall(_:_:)
Extension methodChecks if all elements in a structure match a given predicate.
Declaration
Swift
static func forall<A>( _ fa: Kind<Self, A>, _ predicate: @escaping (A) -> Bool) -> Bool
Parameters
fa
Structure of values where all elements should match the predicate.
predicate
Predicate.
Return Value
A boolean value indicating if all elements in the structure match the predicate.
-
count(_:)
Extension methodCounts how many elements a structure contains.
Declaration
Swift
static func count<A>(_ fa: Kind<Self, A>) -> Int64
Parameters
fa
Structure of values.
Return Value
An integer value with the count of how many elements are contained in the structure.
-
get(_:_:)
Extension methodObtains a specific element of a structure of elements given its indexed position.
Parameters
fa
Structure of values.
index
Indexed position of the element to retrieve.
Return Value
A value if there is any at the given position, or
Option.none
otherwise. -
foldM(_:_:_:)
Extension methodPerforms a monadic left fold from the source context to the target monad.
Declaration
Parameters
fa
Structure of values.
b
Initial value for the fold.
f
Folding function.
Return Value
Summary value resulting from the folding process in the context of the target monad.