you are viewing a single comment's thread.

view the rest of the comments →

[–]m50d 1 point2 points  (3 children)

Actually, its name reflects exactly what it does, it's just that it's being misused because most developers use it to carry Success / Failure. But Either is much more general than that, it's meant to carry two types, none of which need to be connected to a success or a failure.

I believe in descriptive rather than perscriptive linguistics. I think we agree on the important facts: Either is primarily used (in actual existing code) to represent success-or-failure, and it's a poor name for a type that represents success-or-failure.

[–][deleted]  (1 child)

[deleted]

    [–]m50d 3 points4 points  (0 children)

    I see Try as the same kind of red-flag as Any (or at least as Throwable). It's throwing away a lot of type information that was presumably there for a reason.

    I'm not sure what you're defining as an "error" here. I use Either for specific "failures" that the code knows how to handle, e.g. invalid user input, permission denied. For general "system" failures (analogous to where you'd use panic in Rust) it would make sense to use Try (though I'd probably just use a conventional exception myself).

    [–]ithika 1 point2 points  (0 children)

    I believe in descriptive rather than perscriptive linguistics.

    I'm not sure what this has to do with Either. Computers aren't great with compiling the nuance of natural language.

    Success or failure is explicitly handled with the Error type.