Skip to content
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

move catching to either object and make it an either block operator #167

Merged

Conversation

lbialy
Copy link
Contributor

@lbialy lbialy commented Jun 29, 2024

also fixes unreachable case warning by adding specialised ok() operators:

[warn] -- [E030] Match case Unreachable Warning: /Users/lbialy/Projects/foss/ox/core/src/test/scala/ox/EitherTest.scala:145:65
[warn] 145 |    val r1 = either((1 to 20).toVector.mapPar(3)(i => Right(i).ok()))
[warn]     |                                                      ^^^^^^^^^^^^^
[warn]     |                                                      Unreachable case
[warn]     |---------------------------------------------------------------------------
[warn]     |Inline stack trace
[warn]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[warn]     |This location contains code that was inlined from either.scala:56
[warn]  56 |            case Left(e)  => break(Left(e))
[warn]     |                 ^^^^^^^
[warn]      ---------------------------------------------------------------------------
[warn] one warning found

@@ -42,6 +47,23 @@ object either:
) nn: NotNested
): Either[E, A] = boundary(Right(body))

extension [E, A](inline t: Right[E, A])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the comment in code, as to why we need the specialised left/right variants? (avoiding compiler warnings)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -42,6 +47,23 @@ object either:
) nn: NotNested
): Either[E, A] = boundary(Right(body))

extension [E, A](inline t: Right[E, A])
/** Unwrap the value of the `Either`, returning value of type `A` on guaranteed `Right` case. */
transparent inline def ok(): A =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be simplified to t.value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@adamw adamw merged commit 6771b49 into softwaremill:master Jul 1, 2024
5 checks passed
@adamw
Copy link
Member

adamw commented Jul 1, 2024

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants