getSemigroup<L, R> static method
- Semigroup<
R> semigroup
Build a Semigroup<Either>
from a Semigroup.
If both are Right, then return Right containing the result of combine
from
semigroup
. Otherwise return Right if any of the two Either
is Right.
When both are Left, return the first Either
.
Implementation
static Semigroup<Either<L, R>> getSemigroup<L, R>(Semigroup<R> semigroup) =>
Semigroup.instance((e1, e2) => e2.match(
(_) => e1,
(r2) => e1.match(
(_) => e2, (r1) => Either.of(semigroup.combine(r1, r2)))));