Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Left foo and Right err alone do not act like exceptions: you need more baggage for that, which Haskell supports and encourages. When you define this in terms of a monad--not just a data type that has the same features, but part of a reusable category of types--you can provide special syntax for it, which Haskell does: if you have a language claim to have "monadic exceptions" without having a type class for monad and some reasonable support for working with monads, you should frankly question whether the people who designed the language understood what monads were in the first place. In Haskell, you can define operators on Either which allow you to use the generic do notation to achieve something with the feel of exceptions but with fully programmatic behavior: languages like Go and even Rust seem to want the downsides without gaining the benefits, which is just depressing.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: