toEither<L> method

Either<L, T> toEither<L>({
  1. L? l,
  2. L get()?,
})

Implementation

Either<L, T> toEither<L>({L? l, L Function()? get}) {
  assert((l != null) ^ (get != null));
  get ??= () => l!;
  return visit<Either<L, T>>(
    just: (v) => Right<L, T>(v),
    none: () => Left<L, T>(get!()),
  );
}