-
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
Fix traverse
for Either
and Option
#3000
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.
There are a few missing imports in the ReplaceWith
expressions
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Francisco Diaz <francisco.d@47deg.com>
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.
Apart from @franciscodr suggestions, LGTM!
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.
Thanks, @serras!
@nomisRev realized that our current implementations of
traverse
do not respect the expected laws. Let's compare with Haskell (whereJust
is the equivalent ofSome
, and[x]
meanslistOf(x)
).However, our current implementation would return
None
and an empty list in those cases. This PR implements the law-abiding implementations, which returnLeft
wrapped in the corresponding type instead of the "error path" of those.One important question here is whether we should consider this a bug, and thus just release the modifier implementation as part of 1.2.0, or whether this is a breaking change, and thus we should wait until 2.0 and release this fixed implementation under a different name.
Note: the implementation for
Ior
seems to be lawful.