Simplifying Option Handling in Effect Pipeline

I have this code right now:

const program = pipe(
  stringArr,
  Effect.forEach((e) => getCalibrationValue(e)),
  Effect.map((arr) => arr.flatMap(Option.getOrElse(() => 0))),
  Effect.map(Number.sumAll),
  Effect.tap((val) => Effect.log(val)),
)


getCalibrationValue returns an array of Options which could have numeric values which need to be summed together:

[
    { _id: 'Option', _tag: 'Some', value: 12 },
    { _id: 'Option', _tag: 'Some', value: 34 },
    { _id: 'Option', _tag: 'None' }
  ]


Is there a cleaner way to parse the existing values other than doing Effect.map((arr) => arr.flatMap(Option.getOrElse(() => 0)))?
Was this page helpful?