typeclass-proposal
typeclass-proposal copied to clipboard
Typeclass inheritance syntax proposal
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
}
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?
that's a good point