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

Add POptionals into Ior's left and right #893

Merged
merged 1 commit into from
Sep 10, 2020

Conversation

chwthewke
Copy link
Contributor

Hello,

This proposal is to add

theseLeft[A, B, C]: POptional[Ior[A, B], Ior[C, B], A, C]
and
theseRight[A, B, C]: POptional[Ior[A, B], Ior[A, C], B, C]

which can look into the left and right parts of an Ior and modify the value if present.

TheseSpec was amended with the appropriate law checks, and I've run the (jvm) tests successfully.

Is this of any interest?

Thanks

@@ -19,6 +20,16 @@ trait TheseOptics {
case Right(b) => That(b)
}

def theseLeft[A, B, C]: POptional[Ior[A, B], Ior[C, B], A, C] =
Copy link
Member

Choose a reason for hiding this comment

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

would you mind to rename those pTheseLeft and pTheseRight and create monophormic aliases e.g. theseLeft[A, B] = pTheseLeft[A, B, A]?
This is because monomoprhic optics have better type inference.

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!

theseLeft[A, B, C]: POptional[Ior[A, B], Ior[C, B], A, C]
and
theseRight[A, B, C]: POptional[Ior[A, B], Ior[A, C], B, C]

can look into the left and right parts
of an Ior and modify any present value.
@julien-truffaut
Copy link
Member

Awesome, great work @chwthewke

@julien-truffaut julien-truffaut merged commit 28cc3ec into optics-dev:master Sep 10, 2020
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