fromEither<L, R> function

Option<R> fromEither<L, R>(
  1. Either<L, R> either
)

Transforms an Either into an Option. Right becomes Some, and Left becomes None.

expect(E.right('hello').chain(fromEither), some('hello'));
expect(E.left('fail').chain(fromEither), none());

Implementation

Option<R> fromEither<L, R>(Either<L, R> either) =>
    either.chain(E.fold((_) => kNone, some));