Effect CommunityEC
Effect Community2y ago
2 replies
Aleks M

Improving Partial Matcher Definitions

Hi channel! Quick question regarding Match - is there nice API to define partial matchers then combine them into exhaustive match later down the road? Here is what I currently have
const matchPart1 = Match.type<Type>().pipe(
  Match.tag(`Variant1`, () => `Here goes variant 1`)
)

const matchPart2 = Match.type<Type>().pipe(
  Match.tag(`Variant2`, () => `Here goes variant 2`)
)

const match = matchPart1.pipe(
  Match.orElse(
    matchPart2.pipe(
      Match.orElse(() => Effect.fail(`Me sad`))
    )
  )
)
Was this page helpful?