effect
effect copied to clipboard
Strict pattern matching
What is the problem this feature would solve?
Walls of unneeded lambdas when pattern matching harm readability. For example:
import { Data } from "effect"
type Example = Data.TaggedEnum<{
A: {},
B: {},
C: {},
// etc
}>
const { $match } = Data.taggedEnum<Example>()
$match({
A: () => "it is A",
B: () => "this time it is B",
C: () => "this is wild, it's C!",
// etc
})
What is the feature you are proposing to solve the problem?
matchX
simply makes each case strict. This has different performance characteristics, however in many cases it's viable and improves readability:
$matchX({
A: "it is A",
B: "this time it is B",
C: "this is wild, it's C!",
// etc
})
This is particularly relevant when there are potentially dozens of sum members.
What alternatives have you considered?
constant
, tolerating the lambdas.