Fair point, I don't disagree with the statement that `Self` can be limiting as the trait is defined for `Functor[A]`. Thus imposing limitations on type system.
You would want for type variable to not be attached directly to a type class on its definition? But still treated as a container type. Something like:
trait Functor:
fun fmap[A, B](f: A -> B, c: Self[A]) -> Self[B];
...
impl Functor for List[A]:
fun fmap[A, B](f: A -> B, l: List[A]) -> List[B]
List::fold(l, Nil[B], (t, h) => Cons(f(h), t))
...
The above would compile, but the Functor wouldn't be treated of a higher kind in the type-system. I'll try to work a flexible solution, thanks for the great callout!
You would want for type variable to not be attached directly to a type class on its definition? But still treated as a container type. Something like:
The above would compile, but the Functor wouldn't be treated of a higher kind in the type-system. I'll try to work a flexible solution, thanks for the great callout!