either
library
Functions
alt <L , R > (Either <L , R > onLeft (L left ) )
→ Either <L , R > Function(Either <L , R > either )
Recieves an Either , and if it is a Left value replaces it with an
alt ernative Either determined by executing the onLeft
callback.
chainNullableK <L , R , R2 > (R2? f (R right ), L orElse (R right ) )
→ Either <L , R2 > Function(Either <L , R > value )
A wrapper for fromNullableK , that allows for chaining.
chainTryCatchK <L , R , R2 > (R2 f (R right ), L onError (dynamic error , StackTrace stack ) )
→ Either <L , R2 > Function(Either <L , R > value )
Runs the given function, and the result is wrapped in a Right .
If it raises an error, then the onError
callback determines the Left
value.
Do <E , A > (DoFunction <E , A > f )
→ Either <E , A >
filter <L , R > (bool predicate (R right ), L orElse (R right ) )
→ Either <L , R > Function(Either <L , R > either )
Maybe converts an Either to a Left , determined by the given predicate
.
flatMap <L , R , NR > (Either <L , NR > f (R value ) )
→ Either <L , NR > Function(Either <L , R > either )
Transforms Right values with the given function, that returns another Either .
The resulting Either is then flattened / replaces the existing value.
flatMapTuple2 <L , R , R2 > (Either <L , R2 > f (R value ) )
→ Either <L , dynamic > Function(Either <L , R > either )
A variant of flatMap that appends the result to a tuple.
flatMapTuple3 <L , R , R2 , R3 > (Either <L , R3 > f (dynamic a ) )
→ Either <L , Tuple3 <R , R2 , R3 > > Function(Either <L , dynamic > either )
A variant of flatMap that appends the result to a tuple.
fold <L , R , T > (T ifLeft (L left ), T ifRight (R right ) )
→ T Function(Either <L , R > either )
Transforms an Either using the ifLeft
and ifRight
functions.
fromNullable <L , R > (R? value , Lazy <L > orElse )
→ Either <L , R >
Create an Either from a nullable value.
If the value is null
, then the result of the orElse
function is used
as a Left value.
fromNullableK <A , L , R > (R? f (A value ), L orElse (A value ) )
→ Either <L , R > Function(A value )
A wrapper for fromNullable , that returns a function that accepts a
value to be transformed.
fromNullableWith <L , R > (Lazy <L > orElse )
→ Either <L , R > Function(R? value )
A fromNullable variant that enforces the left and right types.
Useful for function composition.
fromOption <L , R > (L onNone () )
→ Either <L , R > Function(Option <R > option )
Converts an Option into an Either .
If the Option is Some , then a Right is returned with the wrapped
value.
Otherwise, onNone
will determine the Left value to return.
fromPredicate <L , R > (R value , bool predicate (R value ), L orElse (R value ) )
→ Either <L , R >
Create an Either from a function that returns a bool .
fromPredicateK <L , R > (bool predicate (R value ), L orElse (R value ) )
→ Either <L , R > Function(R value )
Wrapper for fromPredicate , that returns a function which transforms a
value into an Either .
getOrElse <L , R > (R onLeft (L left ) )
→ R Function(Either <L , R > either )
Unwraps an Either . If it is a Right value, then it returns the unwrapped
value. If it is a Left , then the onLeft
callback determines the fallback.
isLeft <L , R > (Either <L , R > either )
→ bool
Returns true
if the Either is a Left .
isRight <L , R > (Either <L , R > either )
→ bool
Returns true
if the Either is a Right .
left <L , R > (L value )
→ Either <L , R >
Returns an Either that resolves to a Left value.
map <L , R , NR > (NR f (R value ) )
→ Either <L , NR > Function(Either <L , R > either )
Transforms the wrapped value if the Either is a Right .
mapLeft <L1 , L2 , R > (L2 f (L1 value ) )
→ Either <L2 , R > Function(Either <L1 , R > either )
Transforms the wrapped value if the Either is a Left .
right <L , R > (R value )
→ Either <L , R >
Returns an Either that resolves to a Right value.
sequence <L , R > (Iterable <Either <L , R > > arr )
→ Either <L , IList <R > >
Transform an iterable of Either , into an Either containing an IList of
the results.
swap <L , R > (Either <L , R > either )
→ Either <R , L >
Swaps the Left and Right type values.
tap <L , R > (void f (R value ) )
→ Either <L , R > Function(Either <L , R > either )
Perform a side effect on the Either , if it is a Right .
traverse <L , R1 , R2 > (Either <L , R2 > f (R1 a ) )
→ Either <L , IList <R2 > > Function(Iterable <R1 > )
Transform an iterable of Either , into an Either containing an IList of
the results.
tryCatch <L , R > (Lazy <R > f , L onError (dynamic error , StackTrace stack ) )
→ Either <L , R >
Runs the given function, and the result is wrapped in a Right .
If it raises an error, then the onError
callback determines the Left
value.
tryCatchK <A , L , R > (R f (A value ), L onError (dynamic error , StackTrace stack ) )
→ Either <L , R > Function(A value )
Runs the given function, and the result is wrapped in a Right .
If it raises an error, then the onError
callback determines the Left
value.
unwrap <L , R > (Either <L , R > either )
→ R
Unwraps the value of an Either , throwing if the value is Left .
Typedefs
DoFunction <E , A >
= A Function(_DoAdapter<E > $ )