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

Haskell's Either type is conventionally used exactly like that--pretend that Right val is Just val and Left err is Error err.

The reason it doesn't have those names is because it is more general; you can also use Either to model things like early termination. The generic names just make it clearer that it isn't exclusively for error handling unlike exceptions. In other languages using exceptions for more generic control flow is considered poor style, but in Haskell using Either for non-error cases is completely reasonable.



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

Search: