Type-type in a type synonym
2 answers
Depending on your use case, you can emulate a type level function by providing implications for the cases (so much works formless):
sealed trait Foo[T] {
type Out
}
object Foo {
implicit object IntFoo extends Foo[Int] {
type Out = String
}
implicit def list[A] = new Foo[List[A]] {
...
}
}
def myPolymorphicFunction[T](t: T)(implicit foo: Foo[T]): foo.Out = ...
+1
source to share