3 ms·
Either is a sum type. What if I don't want that. It's not about handling errors per se, but modeling the type.
by jjaredsimpson 8y ago
Either is a sum type. What if I don't want that. It's not about handling errors per se, but modeling the type.
- amelius 8y agoYes, I understand. But by "implicitly" I really meant that. You don't see the type, only the compiler does. The programmer only sees the non-error part of the type (the "Right" part of Either).
- jjaredsimpson 8y agoHow could this work? I specify an interface to an api. C Foo(A a) = ... Someone then provides me with some not-A error value. What should I do? What do you mean by implicit.
- KirinDave 8y ago> Either is a sum type. What if I don't want that. Product types work as well, if you want. But unless your return type is a monoid (or like, a semilattice maybe?) then you're going to end up with Sum Types somewhere. The vast, vast majority of software engineers and students work with sum types every day and they're totally fine with them. Most languages implicitly sum many values with null.