I know this question is deep type level programming and my failure is due to lack of knowledge. but I'd like to know at least how to get this one to compile. I need the compiler to figure out that my tuple2 can be a Higher-Kinded type in the context.
trait Extract[T[_],A]{
def extract(t: T[A]): A
}
object Extract{
type T2[B] = {type l[X] = (X,B)}
implicit def forTuple2[A,B] = new Extract[T2[B]#l,A] {
override def extract(t: (A, B)): A = t._1
}
}
def method[T[_],A](a: T[A])(implicit extractor: Extract[T,A]): A = extractor.extract(a)
method[Extract.T2[String]#l,Int]((1,"hi")) //this works but is useless.
//the whole point is to get the compiler to do the heavy lifting And in
//this case it means inferring that a tuple2 of (X,whatever) is a T[X] for the context
anything as much close to my goal as possible is appreciated. I also know shapeless has a library dedicated to this stuff. but let's assume shapeless doesn't exist to solve my problem.