Open yangzai opened 4 years ago
this suggestion doesn't seem to have any attracted much interest. should we leave the ticket open?
In
val g = new (Id ~> Option) { def run[A](x: Id[A]): Option[A] = Some(x) }
The static type is Id ~> Option
. If you need a singleton type have you seen if the following works?
val gDefn = new (Id ~> Option) {
def run[A](x: Id[A]): Option[A] = Some(x)
}
val g: gDefn.type = gDefn
the[Case1.Aux[g.type, Id[Int], Option[Int]]]
@dwijnand nope. I still can't get it to work. I'm testing with:
object Shape extends App {
import shapeless._
import shapeless.PolyDefns._
object G extends (Id ~> Option) {
def apply[A](x: Id[A]): Option[A] = Some(x)
}
val gDefn = new (Id ~> Option) {
// def run[A](x: Id[A]): Option[A] = Some(x)
override def apply[T](x: Id[T]): Option[T] = Some(x)
}
val g: gDefn.type = gDefn
the[Case1.Aux[G.type, Id[Int], Option[Int]]] //compiles
the[Case1.Aux[g.type, Id[Int], Option[Int]]] //does not compile
the[Case1.Aux[gDefn.type, Id[Int], Option[Int]]] //does not compile
}
Error message:
could not find implicit value for parameter t: shapeless.PolyDefns.Case1.Aux[Shape.g.type,shapeless.Id[Int],Option[Int]]
the[Case1.Aux[g.type, Id[Int], Option[Int]]] //does not compile
Currently
kind-projector
allowsto be rewritten as
I was wondering if there could be an alternative syntax that rewrites to
in situations where the singleton type
g.type
is required.i.e. in Shapeless
should compile.