-
-
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 ContravariantCartesian typeclass and for Tuple2 add Monad and FlatMap #1299
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1299 +/- ##
==========================================
- Coverage 90.66% 90.63% -0.04%
==========================================
Files 236 237 +1
Lines 3684 3725 +41
Branches 56 58 +2
==========================================
+ Hits 3340 3376 +36
- Misses 344 349 +5
Continue to review full report at Codecov.
|
LGTM 👍 |
@@ -1,9 +1,12 @@ | |||
package cats | |||
package instances | |||
|
|||
import data.Xor |
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.
Either! :D
#1289 is merged now - looks like this change doesn't have a merge conflict but I suspect if merged it will break the build :) |
I'll update, get the coverage positive and try again.
|
I think this is green now, except for the PR failing because of the |
👍 |
👍 |
These new instances should be isomorphic to
WriterT[Id, A, B]
instances, but there may be cases where you already have a tuple2 and want to use a monad.This approach can be generalized to
TupleN
, but I am not sure it yet justifies code-gen or macros for this purpose.Interestingly, one could make a
Monad
for a general case-class that is generic in at least the last parameter, but that may be going too far.I also added
Cartesian[Eq]
to make the tests easier (otherwise I needed to plumb some new implicits everywhere).