logoalt Hacker News

mattalextoday at 7:10 AM1 replyview on HN

Of course you can: you just have to define it in your type. The output set becomes a union type of the normal output and whatever you want as an exception.

If you write this as a monad, your get very similar syntax to procedural code.


Replies

rienbdjtoday at 8:12 AM

I get what you are saying, but…

An exception is different to an Either result type. Exceptions short circuit execution and walk up the call tree to the nearest handler. They also have very different optimization in practice (eg in C++)

show 1 reply