Seeking Better Pattern Implementation in Effect Land

Hi, is there a better way to achieve this particular pattern using effect? In fp-ts I'd have used Either.reduce or getApplicativeMonoid (maybe?) but I'm not sure what to reach for in effect land. Thanks!

export type Styles = Either.Either<TokenError, CSSObjectWithTokens>;

export const mergeStyles = (...styles: Styles[]): Styles =>
  styles.reduce(
    (acc, item) =>
      pipe(
        acc,
        Either.flatMap((unpackedA) =>
          pipe(
            item,
            Either.map((unpackedB) => ({ ...unpackedA, ...unpackedB }))
          )
        )
      ),
    Either.right({}) as Styles
  );
Was this page helpful?