4 ms·
They make it near impossible to extend from the outside. I can pass a Reader interface to your function, but I cannot (easily) add a > | UnusualProtocol(Socke
by fredrikholm 1y ago
They make it near impossible to extend from the outside.
I can pass a Reader interface to your function, but I cannot (easily) add a
> | UnusualProtocol(Socket)
as a third party consumer.
Other than that, sum types are the better abstraction. With exhaustive first class pattern matching (eg. with proper matching on destructuring), nothing comes close in terms of ergonomics.
- hermanradtke 1y agoThat is a feature. Compose instead of extending.
- Yoric 1y agoOCaml has extensible sum types. They work very nicely for some ranges of problems.