-
-
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
Improvements to Inject. #1557
Improvements to Inject. #1557
Conversation
- move it back to cats-core (near `Coproduct`) - make `inj`/`prj` natural transformations - add `apply`/`unapply` (lowered `inj`/`prj`) - define `Free.roll` - move `injectRoll` (née `Inject.inject`) and `match_` to `Free` - reintroduce "null identity" test (written by @edmundnoble)
These are largely changes needed to ease Quasar’s migration. |
@@ -0,0 +1,81 @@ | |||
package cats | |||
|
|||
// import cats.arrow.FunctionK |
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.
woops
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, I apparently broke tut. Ok, fixes in the morning 😅
sealed abstract class Inject[F[_], G[_]] { | ||
def inj: FunctionK[F, G] | ||
|
||
def prj: FunctionK[G, λ[α => Option[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.
Should we call these inject
and project
?
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’m fine with either. The current ones match the paper and Scalaz. Also, Matryoshka defines project
, so I don’t mind the lack of collision 😁
@notxcain Sorry, I haven’t seen that. |
|
||
import cats.arrow.FunctionK | ||
import cats.data.Coproduct | ||
import cats.syntax.either._ |
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.
unused import here breaking the build
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.
Thanks. I have a false memory of seeing a green build, so this would have sat for a while before I noticed.
Codecov Report
@@ Coverage Diff @@
## master #1557 +/- ##
=========================================
+ Coverage 92.48% 92.5% +0.01%
=========================================
Files 246 246
Lines 3886 3895 +9
Branches 132 134 +2
=========================================
+ Hits 3594 3603 +9
Misses 292 292
Continue to review full report at Codecov.
|
Sorry my bad. The either syntax is used in scala 2.11 and 2.10 withi this |
@kailuowang Yeah – I brought this up on the gitter channel. @paulp mentioned ghik/silencer, but that doesn’t support 2.10. I’ll try the |
Otherwise we need it for 2.10 & 2.11 and need to _not_ have it for 2.12.
👍 LGTM, since this is a breaking change, we might want to wait for a third maintainer sign-off. |
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 looks great. Thanks also for the inject
/ injectRoll
improvements.
merging with three sign-offs |
Coproduct
)inj
/prj
natural transformationsapply
/unapply
(loweredinj
/prj
)Free.roll
injectRoll
(néeInject.inject
) andmatch_
toFree