-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add Validated.unit
#4420
Conversation
Validated.unit
method to expose cached valid unit valueValidated.unit
/** | ||
* Cached value of `Valid(())` to avoid allocations for a common case. | ||
*/ | ||
final def unit[E]: Validated[E, Unit] = Validated.validUnit |
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! Do we need the type parameter to help with inference or would Validated[Nothing, Unit]
work fine?
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.
Not really sure, I followed an example from Either.unit
for consistency.
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.
In some obscure cases, it might help, actually, but I don't know off the top of my head
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 see, I didn't find any clues in #3346. Either.unit
works well enough so this seems fine then :)
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.
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.
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.
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.
No description provided.