-
Notifications
You must be signed in to change notification settings - Fork 451
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
Removes autobind DSL in favor of getOrElse #2968
Conversation
Kover Report
|
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.
I think this is a good move, we trade off an extra call to bind
by what I think is a more orthogonal separation of concerns.
@@ -128,7 +165,7 @@ public interface Raise<in R> { | |||
fold({ raise(it) }, ::identity) | |||
|
|||
@Deprecated( | |||
"Use recover or effect & recover instead", | |||
"Use getOrElse on Raise, Effect or EagerEffect instead.", | |||
ReplaceWith("effect { f() }") |
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.
Should the replacement use getOrElse
too?
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 is deprecating the attempt { f() } catch { g() }
block, but it exists out of two pieces. So I am unsure what is the best thing to do here.
f
is should be refactored to Raise
, but that is a different piece in the user code. That is why I recommended effect { }
. My train of thought:
- Refactor
attempt { f() }
toeffect { f() }
user gets rid of theattempt
call - Refactor
catch
togetOrElse { g() }
user gets rid of thecatch
call - Refactor
arrow.core.continuations.effect
toarrow.core.raise.effect
, the lambda body should be source-compatible
POC based on a discussion on Slack, https://kotlinlang.slack.com/archives/C5UPMM0A0/p1678220999183369
This POC removes autobind DSL syntax, and favours
getOrElse
as a replacement in most cases. Which is consistent across all data types. Updates all the tests to reflect this new usage.Also applies hygiene to
Either
(needs to be moved to other PR if this is not accepted):leftOrNull
inEither
(should we add it forEffect
/EagerEffect
?)recover
<~>catch
method, and only keepscatch
for reifiedT : Throwable
.catchOrThrow
asEither
alternative tocatch
DSL.