[Haskell-cafe] Bool is not...safe?!
olf at aatal-apotheke.de
Fri Jul 6 20:04:43 UTC 2018
> Am 05.07.2018 um 22:39 schrieb Olga Ershova <blaze at ruddy.ru>:
> On Thu, Jul 5, 2018 at 4:27 PM Olaf Klinke <olf at aatal-apotheke.de> wrote:
> Does anyone know whether the C and C++ folks are now using more informative structs as return types?
> When returning errors, they call them "exceptions".
Quite so. One might say that the equivalent of try...catch blocks in Haskell is the pattern match
case (action :: Either err a) of
Right result -> ...
Left err -> deal_with err
But what keeps bugging me about exceptions is this: When working with libraries having nested dependencies, is there a way of knowing the complete set of exceptions that might be thrown by a block of code? It is generally considered bad style to write a catch-all. Instead, only catch the exceptions you know how to deal with. But if I don't know what can be thrown, then I can not make my code bullet-proof. The explicit return type seems the clearer approach to this problem.
More information about the Haskell-Cafe