getMonoid<T> static method
Build an instance of Monoid in which the empty value is None and the
combine function uses the given semigroup to combine the values of both Option
if they are both Some.
If one of the Option is None, then calling combine returns None.
Implementation
static Monoid<Option<T>> getMonoid<T>(Semigroup<T> semigroup) =>
Monoid.instance(
const Option.none(),
(a1, a2) => a1.flatMap((v1) => a2.flatMap(
(v2) => Some(semigroup.combine(v1, v2)),
)));