-
-
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
XorT.ensure method #927
XorT.ensure method #927
Conversation
d46f027
to
b3cd30a
Compare
Current coverage is
|
@@ -51,6 +51,8 @@ final case class XorT[F[_], A, B](value: F[A Xor B]) { | |||
|
|||
def exists(f: B => Boolean)(implicit F: Functor[F]): F[Boolean] = F.map(value)(_.exists(f)) | |||
|
|||
def ensure[AA >: A](ifLeft: => AA)(f: B => Boolean)(implicit F: Functor[F]): XorT[F, AA, B] = XorT(F.map(value)(_.ensure(ifLeft)(f))) |
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.
The name ifLeft
surprised me. This is the value that is used if the input is a Right
but the predicate fails, right? I see that you are just following the name used in Xor
, but I'm thinking we should probably change both of these to ifFalse
, whenFalse
, predicateFailed
or something like that. What do you think?
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.
Well, in case of predicate falling the whole XorT
"falls" to the left branch, it might be an explanation :)
But no problem, I could rename both.
Thanks, @imliar! I like this. I left one minor comment and am interested in your thoughts on it. |
b3cd30a
to
c4b4134
Compare
@ceedubs Done |
@imliar great, thanks! 👍 Are people happy with |
👍 |
#926