typeclass-proposal icon indicating copy to clipboard operation
typeclass-proposal copied to clipboard

Typeclass inheritance syntax proposal

Open ivanopagano opened this issue 6 years ago • 2 comments

in the type classes doc you suggest using the following syntax to imply type class "requirements", which introduces a previously unused notation:

type class Monoid[A] : Semigroup[A] {
  def empty: A
}

What would you think instead of re-using the existing type-bounds notation as in the following snippet?

type class Monoid[A: Semigroup] {
  def empty: A
}

ivanopagano avatar Jun 13 '18 08:06 ivanopagano

That's a very interesting proposal, thanks! I like it in theory, but I don't think it works for all type classes out there. For example, consider something like Parallel:

type class NonEmptyParallel[F[_]: FlatMap, G[_]: Apply] {
  ...
}

type class Parallel[F[_], G[_]] // How to imply NonEmptyParallel here?

LukaJCB avatar Jun 13 '18 09:06 LukaJCB

that's a good point

ivanopagano avatar Jun 13 '18 10:06 ivanopagano