ptal / expected

What did you expect?
113 stars 18 forks source link

Should fmap/mbind/then catch exceptions? #32

Closed ptal closed 10 years ago

ptal commented 10 years ago

Expected can be viewed as interfacing between a monadic code and an exception-throwing code. It could be convenient to call a trait method when an exception is thrown inside fmap/mbind or then method. The default trait method would rethrow if the contained error type is not an exception_ptr.

Another possibility is to have different overload for the two possibilities, what do you think?

viboes commented 10 years ago

There is already the function make_expected_from_call

The user could always do

e.mbind([](E& e){ return make_expected_from_call([](){ return f(e); }));

This is cumbersome, maybe, an adaptor will be better e.mbind(catch_all(f));

viboes commented 10 years ago

See #42

ptal commented 10 years ago

Close regarding #42, it's good for me.