either library

Classes

Either<A, B>
Either is a type representing one of two possible values, A or B. This class is part of the Either type system used in functional programming.
EitherEq<A, B>
Defines equality for instances of Either.
EitherOrd<A, B>
A class that extends Ord to provide a custom ordering for Either values.
Left<A, B>
Left is a subclass of Either indicating that the value is of type A. It encapsulates or "wraps" that value.
Right is a subclass of Either indicating that the value is of type B. It encapsulates or "wraps" that value.

Properties

chain Either<A, C> Function(Either<A, B>) Function<A, B, C>(Either<A, C> fn(B))
Alias for flatMap.
final
chainFirst TapFunction<A, B> Function<A, B>(void f(B))
Alias for tap.
final
fold → C Function(Either<A, B>) Function<A, B, C>(C onLeft(A), C onRight(B))
Alias for match.
final
An alias for of, used to wrap the given value in a Right.
final

Functions

ap<A, B, C>(Either<A, B Function(C)> fnEither) Either<A, B> Function(Either<A, C>)
Applies a function inside an Either to a value inside another Either.
flatMap<A, B, C>(Either<A, C> fn(B)) Either<A, C> Function(Either<A, B>)
FlatMaps over the Either type.
fromOption<A, B>(A leftValue()) Either<A, B> Function(Option<B> option)
A function that takes a function that produces a leftValue and returns a function that converts an Option into an Either that is Left with the provided value if the option is None, and Right with the value from Some if the option is Some.
fromPredicate<A, B>(Predicate<B> predicate, A leftValue()) Either<A, B> Function(B value)
A function that takes a predicate and a function that produces a leftValue. It returns a function that takes a value and returns an Either that is Right with the provided value if the predicate returns true for this value, and Left with the provided value if the predicate returns false.
getEq<A, B>(Eq<A> leftEq, Eq<B> rightEq) Eq<Either<A, B>>
Returns an Eq for Either<A, B>, given an Eq<A> and Eq<B>.
getOrd<A, B>(Ord<A> leftOrd, Ord<B> rightOrd) Ord<Either<A, B>>
Returns an Ord instance for comparing Either values based on the provided orderings for the Left and Right types.
getOrElse<A, B>(B defaultFunction()) → B Function(Either<A, B>)
Returns a function that, when provided with an Either<A, B>, will yield the value inside if it's a Right, or the result of the defaultFunction if it's a Left.
left<A, B>(A value) Either<A, B>
Wraps the given value in a Left, indicating the presence of a value of type A.
map<A, B, C>(C fn(B)) Either<A, C> Function(Either<A, B> either)
Maps over the Either type.
match<A, B, C>(C onLeft(A), C onRight(B)) → C Function(Either<A, B>)
Matches an Either<A, B> to execute a function based on its Left or Right value. Using Dart's pattern matching, the match function provides an expressive and concise way to handle Either values without manual type checks.
matchW<A, B, C, D>(D onLeft(A), D onRight(B)) → D Function(Either<A, B>)
Matches the given Either value and returns the result of the respective handler.
of<A, B>(B value) Either<A, B>
Wraps the given value in a Right, indicating the presence of a value of type B.
sequenceList<E, A>(ImmutableList<Either<E, A>> list) Either<E, ImmutableList<A>>
Takes an ImmutableList of Either values and attempts to extract their right-hand values.
swap<A, B>(Either<A, B> either) Either<B, A>
Swaps the inner types of an Either value.
tap<A, B>(void f(B)) TapFunction<A, B>
Takes an Either<A, B> and applies a function to the Right value if it exists. The tap function is often used for debugging or performing side effects.
traverseList<E, A, B>(Either<E, B> f(A), ImmutableList<A> list) Either<E, ImmutableList<B>>
Processes each item of an ImmutableList through a function f that returns an Either, and collects the results into a new ImmutableList.

Typedefs

TapFunction<A, B> = Either<A, B> Function(Either<A, B> either)