79596261

Date: 2025-04-28 10:38:34
Score: 0.5
Natty:
Report link

One way is to do pattern matching over the array. This way I don't have to use any type assertion. Here's the final solution

const result = pipe(
  arrayOfObjects,
  Array.match({
    onEmpty: () => 0,
    onNonEmpty: flow(
      Array.map(o => o.value),
      Array.max(Order.number)
    )
  })
)

Effect playground link for complete solution - https://effect.website/play#490e0fd8564e

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: elango.dev