typeclass-proposal
typeclass-proposal copied to clipboard
Inconsistencies in syntax when defining instances
I noticed, while reading part 3, "Instance Declarations", that you used two different syntaxes:
You start out with a :
.
extension intAdditionSemigroup : new Semigroup[Int] {
def combine(this x: Int)(y: Int) = x + y
}
But later on change that to a normal =
:
extension fooEq[A: Eq] = new Eq[Foo[A]] {
def eqv(this x: Foo[A])(y: Foo[A]): Boolean =
x.a.eqv(y.a)
}
Further on, in part 4, you lose extension
as a keyword and go back to implicit val
s again. Same situation in the last part.
Which of the two do you intend?
Also, slight correction in the "Using default implementations" section:
extension readerApplicativeFunctor[R] :
new Applicative[[A] => Reader[R, A]] with Functor[A] => Reader[R, A]] {
def pure[A](a: A): Reader[R, A] =
Reader(_ => a)
def ap[A, B](this fa: Reader[R, A])(ff: Reader[R, A => B]): Reader[R, B] =
Reader(r => ff.run(r)(fa.run(r)))
}
Just syntactically, your Functor is missing a [
in there, but I don't think that you wrap square brackets around the types in kind-projector (correct me if I'm wrong, I've never used it).
Thank you for pointing this out, I'll try to address it ASAP :)