Hacker News new | ask | show | jobs
by saurik 2101 days ago
Rust doesn't have "monadic error handling" as it doesn't have monads. Haskell has monads and syntax for managing them, so when you declare a type like Result (which is not a monad as merely a data structure) you hide it as a monad (wherein you implement the Monad trait and define how the Result type propagates errors) and then it just becomes part of the usage of do notation in the language (like any other monad). If Rust has gone with monadic error handling I would have been elated, but it didn't: it went for manual, but required, error checking, which was a bit ridiculous in the 2010s and the opposite of monads (which I would argue exceptions are much closer to: they are effectively a hardcoded implementation of Monad for an implicit type wrapper of every function result and a do notation you can't opt out of).