4 ms·
> I can't speak to Rust's solution in practice, but having used Haskell for a long time with union types for errors, I can say they are hardly error-handling ni
by ansible 8y ago
> I can't speak to Rust's solution in practice, but having used Haskell for a long time with union types for errors, I can say they are hardly error-handling nirvana there.
Haskell's Either-like Monads have gone through considerable evolution:
https://www.yesodweb.com/blog/2016/04/fixing-monad-either https://www.yesodweb.com/blog/2016/04/fixing-monad-either
I'd love to hear more from someone familiar with Haskell and Rust to talk about if Rust's Result enum would have the same kinds of issues they've had in the Haskell world.
- steveklabnik 8y agoIt's been a while since I've actually written haskell, but a lot of this is about monads, both Monad and monad transformers, both of which Rust doesn't have. > The broken fail function We don't have this. > The problem with Error Our Error trait (typeclass in haskell terms) had a "description" method that had some issues, so we've deprecated it and provided a default impl. We expect errors to implement a similar type signature, but with the Display/Debug traits, not some sort of fromString trait. > The proper Monad Either instance not applicable > Either for arbitrary error types Rust's Result already works for arbitrary error types; you don't have to actually implement Error for them, so this is a non-issue.