maybeToLeft
Callable
Type parameters
- T
The type held by Just in the Maybe.
- R
The type of the Right value in the returned Either.
Parameters
x: T
The Maybe value to transform. If it is a Just, it is returned as the Left part of an Either.
right: R
The default value to use for the Right part if
x
is Nothing.
Returns [Nothing] extends [T] ? IsEqual<T, Nothing> extends true ? Right<R> : Either<Just<T>, R> : Left<T>
Either a Left containing the Just value or a Right with the default value.
- T
Transforms a Maybe value into an Either type, returning a Left containing the Just value. If the Maybe is Nothing, it returns a Right with a specified default value.
Example