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
catch for EffectScope #2746
Merged
Merged
catch for EffectScope #2746
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4f113bc
catch for EffectScope
serras 822c89b
Update API files
serras 39247b9
Merge branch 'main' into effect-catch
i-walker 8c31fe3
Suggestions by @i-walker + add catch for EagerEffectScope
serras e9b86d2
Update API files
serras f18db85
Suggestions by @nomisRev to improve inference
serras 533f0fc
Remove the intermediate `Attempt` class
serras 4958b48
API dump
serras 9693ab6
Merge branch 'main' into effect-catch
serras c19e720
Better docs based on @i-walker's suggestions
serras b77ce50
Add missing files + apply suggestions
serras c08c236
Fix Knit examples
serras ba8e4f3
Merge branch 'main' into effect-catch
nomisRev 1e1f63e
Introduce forgotten suspend in catch for EffectScope
serras b1197af
Merge branch 'main' into effect-catch
serras 93564cf
Update arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/co…
serras f3907a4
Remove suspend from EagerEffectScope.catch
serras 81b0711
Add attempt/catch test for EagerEffect
serras 08cf9e9
Merge branch 'main' into effect-catch
i-walker File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be an extension due to variance?
This duplicates behaviour with
handleErrorXXX
but it exposes a nicer lambda forhandler
where you can leverage the DSL again by exposingEffectScope<E>
on the receiver of the lambda.I am absolutely up for improving these APIs, and renaming them but we should probably avoid duplicated APIs as much as possible to keep the API surface reasonable.
That being said this signatures reminds me a lot of
Flow#catch
, and it uses the same naming so I am in favour ofcatch
over the currenthandleErrorXXX
&redeemXXX
methods. This seems to cover all 4 APIs with a single nice API.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me the question is how much of the API should be exposed via
EffectScope<E>
as opposed toEffect
. Personally, I'd prefer to stay within the realm ofEffectScope
as much as I could, and only refer toEffect
to "run" the action at the very top level. But I also see this is very much a design choice, so I'll be happy with whatever decision you take.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About not being an extension, I just wrote it directly like that, although it could also be part of
EffectScope
itself. In fact, this opens the decades-old debate: itcatch
part of the "error effect", or is it a "effect transformer" (my definition ofcatch
says that the latter).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also an alternative, using the
UnsafeVariance
, which is fine here.// in EffectScope interface
we can also have the Effect be a parameter, if this is a better encoding