-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: MonadError.transformWith #2161
Comments
1 task
alexandru
added a commit
to alexandru/cats
that referenced
this issue
Apr 23, 2018
This was referenced Apr 23, 2018
Isn't this solved by |
@joan38 It doesn't look like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So
MonadError
hasattempt
andhandleErrorWith
and for many use-cases one has to introduce bothmap
/flatMap
transformations andhandleErrorWith
handlers in the same "frame".E.g. what happens for data types implementing
cats-effect
likecats.effect.IO
andmonix.eval.Task
is something like thisThis is more or less the equivalent of this pattern:
Well the problem is that usage of either
attempt
orhandleErrorWith
involves 2flatMap
(bind) frames instead of one. And as we all know, the performance ofIO
/Task
data types, compared with plain function calls, is terrible.The proposal is to introduce an alternative to
attempt.flatMap
like so:Just did.a fast benchmark to show what the difference can be:
Precedents:
Note — I'd prefer the version with the two function parameters, because I'd rather avoid the extra
Either
boxing.Implementation notes:
cats.effect.IO
is already optimized for this operationmonix.eval.Task
is already optimized for this operationBasically I'd like to not feel bad about adding error handling.
The text was updated successfully, but these errors were encountered: