-
Notifications
You must be signed in to change notification settings - Fork 87
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
Eliminate FunctorT and TraverseT type classes. #51
Conversation
As well as other changes needed in the wake of the directly-recursive overhaul.
Looks like a great simplification so far. |
Yeah, so some comments in that vein …
|
@@ -301,6 +256,185 @@ trait Recursive[T] extends Based[T] { | |||
(implicit R: Corecursive.Aux[R, Base], BF: Functor[Base]) | |||
: R = | |||
cata[R](t)(R.embed(_)) | |||
|
|||
def mapR[U, G[_]: Functor] |
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 and below is pulled from FunctorT
and TraverseT
– it seemed prudent to not get rid of the operations yet (#45 is tracking this), since we use them a bunch in Quasar and I’m just not sure what the right approach is.
There are also some operations moved from earlier in the type class – into the group of things that should be in Birecursive
once that is actually usable.
@@ -28,9 +28,9 @@ sealed class IdOps[A](self: A) { | |||
matryoshka.hyloM(self)(f, g) | |||
|
|||
object ghylo { | |||
def apply[W[_], N[_]] = new Aux[W, N] | |||
def apply[W[_], N[_]] = new PartiallyApplied[W, N] |
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.
Renamed these “helper” classes to match the Cats approach, which is named this way to avoid confusion with the other Aux
pattern. Figured since I was adding new ones, I should make sure the code is consistent.
This is something that multiple implicit lists would make disappear.
* @group algebras | ||
*/ | ||
type AlgebraicTransform[T[_[_]], F[_], G[_]] = F[T[G]] => G[T[G]] // GAlgebraicTransformM[T, Id, Id, F, G] | ||
type AlgebraicGTransform[W[_], T, F[_], G[_]] = F[W[T]] => G[T] |
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.
These new aliases just use the new proper type approach. It means the differ a bit (e.g., the types of AlgebraicTransform
and CoalgebraicTransform
are now the same, so they’re just Transform
).
@@ -69,7 +69,7 @@ class PartialSpec extends Specification with ScalazMatchers with ScalaCheck with | |||
"return after multiple runs" >> prop { (a: Conat, b: Conat) => | |||
val (ai, bi) = (a.cata(height), b.cata(height)) | |||
bi > 0 ==> { | |||
val first = (a + b).transAna(Partial.delay(27)).runFor(ai) | |||
val first = (a + b).transAna[Partial[Int]](Partial.delay(27)).runFor(ai) |
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.
These operations (like the non-trans
operations with the same names) now require a type annotation, because they only know that the result type has a particular functor, but not what proper type that functor has been extracted from.
Different[Mu, Example, Mu[Diff[Mu, Example, ?]]](Empty[Mu[Example]]().embed, NonRec[Mu[Example]]("x", 3).embed).embedT, | ||
Removed[Mu, Example, Mu[Diff[Mu, Example, ?]]](Empty[Mu[Example]]().embed).embedT), | ||
Different[Mu, Example, Mu[Diff[Mu, Example, ?]]](Empty[Mu[Example]]().embed, NonRec[Mu[Example]]("x", 3).embed).embed, | ||
Removed[Mu, Example, Mu[Diff[Mu, Example, ?]]](Empty[Mu[Example]]().embed).embed), |
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.
With the fixed implicits, we can use the *ecursive
ops rather than the *ecursiveT
ops, so now we no longer use the T
ops, and in fact, no longer have an implicit conversion that makes them available.
Current coverage is 72.67% (diff: 71.18%)@@ master #51 diff @@
==========================================
Files 38 37 -1
Lines 649 666 +17
Methods 634 649 +15
Messages 0 0
Branches 15 17 +2
==========================================
+ Hits 477 484 +7
- Misses 172 182 +10
Partials 0 0
|
Ok, @paulp now it‘s yours. Once this gets in, I’ll submit the PR that updates Quasar to use this version. |
@sellout shouldn't |
Ah yes, that is great :) |
I think that's everything concrete I have words for at the moment. Do you want me to make the CorecursiveT change? |
Sure. I like this new thing in the space between code review and pairing 😄 |
@sellout I think it's called code repairing |
I'll merge it after the tests pass. |
As well as other changes needed in the wake of the directly-recursive
overhaul – like fixing
EqualT
/ShowT
implicits, etc.