This repository has been archived by the owner on Nov 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Sufficiency checker complains about a valid instance. #64
Labels
research
We need to carefully think about this.
Comments
sir-wabbit
added
bug
Something isn't working or something might not work.
blocker
Fix this the first opportunity!
labels
Sep 21, 2018
Ah, I think the original code had a bug, the correct order of inheritance is: private trait ComposeApply[F[_], G[_]] extends Apply[Compose[F, G]#L] with ComposeFunctor[F, G] {
val F: Apply[F]
val G: Apply[G]
final override def ap[A, B](fa: F[G[A]])(f: F[G[A => B]]): F[G[B]] =
F.ap(fa)(F.map(f)(gab => G.ap(_)(gab)))
}
private trait ComposeApplicative[F[_], G[_]] extends Applicative[Compose[F, G]#L] with ComposeApply[F, G] {
val F: Applicative[F]
val G: Applicative[G]
final override def pure[A](a: A): F[G[A]] = F.pure(G.pure(a))
} However this results in: i64.scala:81: error: trait ComposeApplicative inherits conflicting members:
method map in trait Applicative of type [A, B](<param> ma: F[G[A]])(<param> f: scala.this.Function1[A,B])F[G[B]] and
method map in trait ComposeFunctor of type [A, B](<param> fa: F[G[A]])(<param> f: scala.this.Function1[A,B])F[G[B]]
(Note: this can be resolved by declaring an override in trait ComposeApplicative.)
private trait ComposeApplicative[F[_], G[_]] extends Applicative[Compose[F, G]#L] with ComposeApply[F, G] {
^ |
This compiles fine: private trait ComposeFunctor[F[_], G[_]] extends Functor[Compose[F, G]#L] {
val F: Functor[F]
val G: Functor[G]
final override def map[A, B](fa: F[G[A]])(f: A => B): F[G[B]] =
F.map(fa)(G.map(_)(f))
}
private trait ComposeApply[F[_], G[_]] extends Apply[Compose[F, G]#L] with ComposeFunctor[F, G] {
val F: Apply[F]
val G: Apply[G]
final override def ap[A, B](fa: F[G[A]])(f: F[G[A => B]]): F[G[B]] =
F.ap(fa)(F.map(f)(gab => G.ap(_)(gab)))
}
private trait ComposeApplicative[F[_], G[_]] extends Applicative[Compose[F, G]#L] with ComposeApply[F, G] {
val F: Applicative[F]
val G: Applicative[G]
final override def pure[A](a: A): F[G[A]] = F.pure(G.pure(a))
} Turns out there is a difference between |
sir-wabbit
removed
blocker
Fix this the first opportunity!
bug
Something isn't working or something might not work.
labels
Sep 22, 2018
So at the end of the (second) day, I am no longer sure it's a bug. I am gonna leave it open for now in case we decide to carefully think about this case (and the interaction between sufficiency and subtyping) later. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Sufficiency checker complains
missing implementation for methods: ap OR (unit AND zip AND map) on new ComposeApplicative[F, G]
.The text was updated successfully, but these errors were encountered: