-
-
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 OptionT.liftF and update related docs and tests. Close issue #659 #667
Conversation
Current coverage is
|
* Lifts the `F[A]` Functor into an `OptionT[F, A]`. | ||
* | ||
*/ | ||
def liftF[F[_], A](fa: F[A])(implicit F: Functor[F]): OptionT[F, A] = OptionT(F.map(fa)(Option(_))) |
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 may not really be something to worry about, but I'm thinking that maybe this should use Some(_)
instead of Option(_)
. The Option.apply
method has logic to turn null
into None
. In Cats we are generally assuming that people aren't passing around null
. But if for some reason they really want to lift a null
value into the OptionT
structure, I don't think we should prevent them from doing that here.
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 used Option(_)
to prevent null
and getting None
instead of Some(null)
in that case, but if you confirm we should not prevent them from doing that I'll change it to Some(_)
.
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 think that it should be consistent with our Applicative[Option].pure
implementation, which uses Some
: https://github.com/non/cats/blob/master/core/src/main/scala/cats/std/option.scala#L14. So yeah, I think we should change this here. I don't think we should conflate the issues of lifting and de-nulling.
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 totally agree! I'll change it to Some(_)
. Thank you.
Thanks, @lambdista! In general, this looks great. I left a couple very minor comments. |
Thank you @ceedubs for your support! |
👍 (assuming the build passes). Thanks again! |
Thank you! 👍 |
👍 Good work! Thanks! 🐈 |
add OptionT.liftF and update related docs and tests. Close issue #659
No description provided.