-
-
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
Unseal InjectK to allow for extension by other libraries #1642
Conversation
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, I don't think practically sealing this buys us anything. This type class is much more useful as "injective natural transformations", rather than "how to get in and out of EitherK".
The only benefit, IMHO, of leaving it sealed is that the implementation stays true to the reference paper. That being said, also I prefer that |
Codecov Report
@@ Coverage Diff @@
## master #1642 +/- ##
=======================================
Coverage 93.37% 93.37%
=======================================
Files 240 240
Lines 3941 3941
Branches 138 138
=======================================
Hits 3680 3680
Misses 261 261
Continue to review full report at Codecov.
|
👍 for the change. Since we'd like to treat this as a typeclass, how about making it a trait? We may decide to add a Edit: another question: why not making |
b266f1b
to
102f963
Compare
Update: I switched the class to a trait and added final to apply/unapply. |
Thanks very much @andyscott. It's probably too much to ask for this PR but I started to wonder if we should/can add laws to this new typeclass. We don't have typeclasses that take two type constructors yet, so it will be a first. |
Adding laws seems reasonable. Would it be okay to handle that with a separate PR (and maybe an issue for discussion purposes)? |
do you want to create an issue for this law or I can create one? @andyscott |
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.
LGTM, I'll wait for another one or two signoff. @edmundnoble do you want to do another quick round?
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 actually don't think we should change the "abstract class" part. Nobody should be using mixin inheritance with a class with an apply
and an unapply
; practically I don't believe anyone will, so the trait
conceptual and bytecode overhead isn't worth it.
@edmundnoble I was thinking the possibility of having a |
102f963
to
be438d1
Compare
be438d1
to
11ddf9e
Compare
I've changed it back to an abstract class. |
@andyscott how do you split Inject apart? You mean taking the |
@kailuowang I like the idea of splitting |
@andyscott it appears to me that you have to have them both available to write laws right? |
@kailuowang I would be fine with |
@kailuowang Yep, for any general roundtrip law(s) you need both. |
@edmundnoble Are changes still needed? Should we move |
@andyscott This gets a 👍 from me after the abstract class change. |
@edmundnoble I've changed it back to abstract class already |
I know. Sorry for the ambiguity ;) |
@andyscott thanks! Let's merge now and we can work on making it a type class for |
It would be extremely useful to open up the injection helpers in Free to support any target coproduct type. This is the simplest solution to address this "issue".
Related gitter conversation: https://gitter.im/typelevel/cats?at=590627c9d32c6f2f0956189d
For discussion:
apply
/unapply
be removed?EitherK
can occur?