3 ms·
I do agree with you that you can encode exceptional conditions via mechanisms like Either, Maybe, and ErrorT; similarly, you can encode C errors via return valu
by JoshTriplett 14y ago
I do agree with you that you can encode exceptional conditions via mechanisms like Either, Maybe, and ErrorT; similarly, you can encode C errors via return values, NULL pointers, and errno. However, ever so often you still run across a Haskell library that decides to use exceptions for error handling, and in such cases, the types do not tell you what exceptions can occur. I'd argue that having those exceptions encoded in the type would make sense as well.
If Haskell's "runtime exceptions" only existed to abort the program, and you couldn't catch them, then I'd agree that encoding them in the type doesn't seem necessary. However, since you can catch them, and often do need to, encoding them in the type would help.
- Evbn 14y agoSo your request is that Haskell force programmers to not throw unchecked exceptions when a checked type could work? That's a PEBKAC, not a language issue.
- JoshTriplett 14y agoNot my point at all. I like the Haskell exception system for some types of error handling, and I think in some cases it works better than Either, ErrorT, or similar mechanisms. I'd still like to have those exceptions reflected in the type. That doesn't mean I'd like an Either or an ErrorT; those don't work like thrown exceptions.