Closed newhoggy closed 1 year ago
Why not excepts? I believe it's more mature.
I tried that first but I didn't get very far. One of the reasons I couldn't get it working is there isn't a combinator that preserves the transformer stack. See snatchM
, which is the same as catchM
except the exception is not plucked from the list of possible errors.
There are possibly other reasons like support for MonadError
, decent error messages, good type inference, flipped catch arguments (which has better ergonomics).
I have also tried and rejected plucky
because it's error messages were very poor.
I even tried fused-effects
but got very stuck when I couldn't get it to work with ResourceT
.
One of the reasons I couldn't get it working is there isn't a combinator that preserves the transformer stack. See snatchM, which is the same as catchM except the exception is not plucked from the list of possible errors.
Not sure I understand what you mean with preserving the transformer stack. Are you looking for onE?
There are possibly other reasons like support for MonadError, decent error messages, good type inference, flipped catch arguments (which has better ergonomics).
Upstream has been responsive and willing to add new instances: https://github.com/haskus/packages/issues/34
Good type inference isn't really possible with open sum types.
onE
seems right.
Let me finish this restructuring and we can take a step back and re-evaluate.
This is coded up. Next step is to add some integration tests.
Includes integration tests now, so I'm more comfortable with refactoring not breaking anything accidentally.
Removed all the pre-oops code.
This PR is ready.
may i ask why you do not just use plucky
? oops
is just another implementation of the same interface.
plucky
was actually the first out of many libraries I tried. I found it had poor error messages and type inference (for example using HLS to infer type signatures) was poor which made it difficult to use.
oops
also has catch combinators with flipped arguments, which is preferable because it allows me to cleanly stack multiple handlers on the same expression without using parentheses. The reliance of parentheses is particularly problematic because adding or removing handlers touches more lines than I'd like.
I wrote some extensive notes on why I chose to go with oops
in another PR: https://github.com/input-output-hk/cardano-node/pull/4777
Why not excepts? I believe it's more mature.