Hacker News new | ask | show | jobs
by dullgiulio 3240 days ago
That's right. But I prefer to decorate each error as it comes back from the callee, writing what I was trying to do that failed. This gives a human readable trace of the problem, and also a unique signature for the error itself.
1 comments

> But I prefer to decorate each error as it comes back from the callee

That's trivially feasible and still shorter than the Go version:

    a <- decorate (squareRoot x)
    b <- decorate (log a)
    c <- decorate (log b)
Outside of the do context, your return value is just that, a value, you can manipulate it using the language's regular tooling. And you can decorate the do context itself if you want the same decoration for all calls in the block.