-
-
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 an ApplicativeError
instance for Kleisli
and a MonadError[Option, Unit]
to std.option
#1029
Added an ApplicativeError
instance for Kleisli
and a MonadError[Option, Unit]
to std.option
#1029
Conversation
@@ -15,8 +15,25 @@ class KleisliTests extends CatsSuite { | |||
implicit def kleisliEq[F[_], A, B](implicit A: Arbitrary[A], FB: Eq[F[B]]): Eq[Kleisli[F, A, B]] = | |||
Eq.by[Kleisli[F, A, B], A => F[B]](_.run) | |||
|
|||
implicit val xorT = XorT.xorTEq[Kleisli[Option, Int, ?], Unit, Int] | |||
|
|||
implicit val optionApplicativeError : ApplicativeError[Option, Unit] = new ApplicativeError[Option, Unit] { |
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.
Do we want to just move this into the main source?
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.
Hmm, I don't really know the use case for it. But one could be like here, in a kleisli, anything else?
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.
Also curious how @ceedubs thinks about this, he suggested it "weird" in gitter right?
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 it could give users an option (hah) to plug in Option
if working with a MonadError
API (I'm guessing Option
can implement MonadError
, not just ApplicativeError
) when they don't care about the errors
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, it's a little weird, but I think I'd approve of it living in the main source. I also want it for #689 :)
7893e77
to
074afaa
Compare
Current coverage is 88.24%
@@ master #1029 diff @@
==========================================
Files 215 215
Lines 2713 2720 +7
Methods 2649 2657 +8
Messages 0 0
Branches 59 58 -1
==========================================
- Hits 2408 2400 -8
- Misses 305 320 +15
Partials 0 0
|
074afaa
to
ecdd103
Compare
Moved |
ecdd103
to
2068080
Compare
ApplicativeError
instance for Kleisli
ApplicativeError
instance for Kleisli
and a MonadError[Option, Unit]
to std.option
implicit val iso = CartesianTests.Isomorphisms.invariant[Kleisli[Option, Int, ?]] | ||
|
||
checkAll("ApplicativeError[Klesili[Option, Int, Int], Unit]", ApplicativeErrorTests[Kleisli[Option, Int, ?], Unit].applicativeError[Int, Int, Int]) |
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.
Should probably run SerializableTests
on this.
47a57d8
to
a917296
Compare
@@ -17,6 +17,9 @@ class OptionTests extends CatsSuite { | |||
checkAll("Option[Int] with Option", TraverseTests[Option].traverse[Int, Int, Int, Int, Option, Option]) | |||
checkAll("Traverse[Option]", SerializableTests.serializable(Traverse[Option])) | |||
|
|||
checkAll("Option with Unit", MonadErrorTests[Option, Unit].monadError[Int, Int, Int]) | |||
checkAll("MonadError[Option, Unit]", SerializableTests.serializable(MonadErrorTests[Option, Unit])) |
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 attempting to serialize MonadErrorTests
instead of the MonadError
instance for 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.
oopz
a917296
to
c52c6ec
Compare
👍 thanks! |
LGTM 👍 |
No description provided.