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 Validated.unit #4420

Merged
merged 1 commit into from
May 12, 2023
Merged

Add Validated.unit #4420

merged 1 commit into from
May 12, 2023

Conversation

VladKopanev
Copy link

No description provided.

@VladKopanev VladKopanev changed the title Add Validated.unit method to expose cached valid unit value Add Validated.unit Apr 11, 2023
/**
* Cached value of `Valid(())` to avoid allocations for a common case.
*/
final def unit[E]: Validated[E, Unit] = Validated.validUnit
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! Do we need the type parameter to help with inference or would Validated[Nothing, Unit] work fine?

Copy link
Author

Choose a reason for hiding this comment

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

Not really sure, I followed an example from Either.unit for consistency.

Copy link
Author

Choose a reason for hiding this comment

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

In some obscure cases, it might help, actually, but I don't know off the top of my head

Copy link
Member

Choose a reason for hiding this comment

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

I see, I didn't find any clues in #3346. Either.unit works well enough so this seems fine then :)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, hard to say. I also wondered if its an artifact of old compilers e.g. 2.11 that couldn't handle these as well.

Copy link
Author

Choose a reason for hiding this comment

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

Possibly yes, I remember stumbling upon such cases a few years back with zio-saga library, but not sure any more if this behaviour still exists in modern versions.

@armanbilge armanbilge merged commit ad8db09 into typelevel:main May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants