-
-
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
added liftTo
syntax to Validated
#2293
Conversation
x match { | ||
case Right(a) => pure(a) | ||
case Left(e) => raiseError(e) | ||
} |
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.
replace fold
to optimize performance ( this way there is no need to create anonymous functions, which take a toll. )
liftTo
syntax to validatedliftTo
syntax to Validated
Codecov Report
@@ Coverage Diff @@
## master #2293 +/- ##
==========================================
+ Coverage 95.01% 95.03% +0.02%
==========================================
Files 337 337
Lines 5835 5840 +5
Branches 216 222 +6
==========================================
+ Hits 5544 5550 +6
+ Misses 291 290 -1
Continue to review full report at Codecov.
|
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.
Looks good to me 👍
I wonder though, if we have opaque types in the future and we want to make Validated
a newtype over Either
(for performance benefits when converting between the two), if this will be redundant. Though of course that's fairly far into the future :)
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.
This is nice!
so that you can lift a
Validated[E, A]
to anyF[A]
that has anApplicative[F, E]
.Note that I placed the syntax in a
ValidatedOps
value class mainly work around the variance requirement. (If the method is insideValidated
you wouldn't be able to useE
andA
in invariant/contravariant position, so you would have to introduce an EE >: E and AA >: A but that requires extra type parameters to be passed in, which beat the purpose of this thing which is mostly ergonomic.