Using Match for Delegating to Other Effects Instead of Switch
Is it possible to use Match instead of a switch statement to delegate to other Effects?
Something like:
type T = {type: “foo”, payload: string} | {type: “bar”, payload: number }
const a:T = {type: “foo”, payload: “cool”}
pipe(
Effect.succeed(a),
Effect.flatMap(
Match.tagsExhaustive(“type”)({
foo: x => Effect.succeed(“ok”),
bar x => Effect.fail(“nope”)
}))
)
Something like:
type T = {type: “foo”, payload: string} | {type: “bar”, payload: number }
const a:T = {type: “foo”, payload: “cool”}
pipe(
Effect.succeed(a),
Effect.flatMap(
Match.tagsExhaustive(“type”)({
foo: x => Effect.succeed(“ok”),
bar x => Effect.fail(“nope”)
}))
)
