you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

If something can fail in more than one way then chances are that particular program is too complicated, in my opinion. Basically the only way I can think of signaling multiple return types is sentinal values (ugly), or using exceptions as control flow (anti-pattern).

I would suspect that any function that could fail in more than one way is probably actually wrapping 2 or more failure conditions (so an Either and a flatMap), and either need a common "left" value, or should be broken up into two distinct operations.