|
|
|
|
|
by jcparkyn
1280 days ago
|
|
It makes generics and higher-order functions much more elegant. Any function of `(a->t)->t`(or many other similar signatures) will automatically be able to return the correct error type if t is a Result<>. Compare this to checked exceptions, where (even in an ideal world) you'd need a separate type parameter for the error type, plus a bunch of extra language features and syntax to make it work. And then what happens if you want to use the same function with _no_ error type? For a concrete example, try using Java's `stream().map()` with checked exceptions. Of course there are implementations of checked exceptions which are much closer to Result than Java's implementation, and in those cases I would agree with you. |
|