4 ms·
Yes, but they usually use some form of monad to hold either an exception or a value. The implementation of >>= (haskell calls it bind, buts it's useful to thin
by scottdw2 15y ago
Yes, but they usually use some form of monad to hold either an exception or a value.
The implementation of >>= (haskell calls it bind, buts it's useful to think of it like an overloaded ";" that takes a continuation as a parameter ) examines the return value and decided wether to run the normal path or the exception path...
It doesn't quite perform the same as exceptions do (it burdens both paths with if checks, whereas imperative exceptions only burden the error path)
But the code you write looks almost identical to exception handling code. It doesn't look like something using if checks.