Effect CommunityEC
Effect Community17mo ago
7 replies
Niklas

Combining Option Values with Monoid in Effect

Hi I'm looking for the right way to do the following in Effect.

import { Option, none, some } from 'fp-ts/Option'; import { getMonoid } from 'fp-ts/Option'; import { MonoidSum } from 'fp-ts/number'; import { concatAll } from 'fp-ts/Monoid'; const options: Option<number>[] = [some(1), none, some(2), none, some(3)]; const monoidOptionNumber = getMonoid(MonoidSum); const result = concatAll(monoidOptionNumber)(options); console.log(result); // Output: Some(6)

I checked in both Option and @effect/typeclass Monoid but can't find anything. Thank you in advance
Was this page helpful?