Open carymrobbins opened 6 years ago
From
ν[Functor[Option]].map[A, B](f => fa => fa.map(f))
not only can the plugin not tell whether the map signature is
def map[A, B](f: A => B)(fa: F[A]): F[B]
or
def map[A, B](f: A => B): F[A] => F[B]
or
def map[A, B]: (A => B) => F[A] => F[B]
but the plugin is not even able to infer parameter types and return type. For return type it is not a problem: we just omit it in the generated code:
new Functor[Option] {
def map[A, B] = f => fa => fa.map(f)
}
But parameter types would have to be specified in the generated code.
Ideally, given this Functor definition -
We could create an instance with pascal via -
However, this doesn't work. We have to define Functor like this instead -
Then the instance compiles. Ideally, we should be able to define it as a polymorphic method and the rewrites should be able to handle it accordingly via an override. Maybe this becomes difficult since I believe this all happens before typer, which means we can't easily access the method signature to override. In that case, maybe there's an alternate way to represent such an override?