I am having a problem with type lambdas. I'm using shapeless hlists, and am trying to infer an hlist of functions to some type X from an hlist of argument types. For some reason, scalac isn't unifying the lambda I have over functions.
type sx[T] = T => String
implicitly[Mapped[HNil, sx]]
This variant works fine. However, this one doesn't work:
trait fx[X] {
type λ[T] = T => X
}
implicitly[Mapped[HNil, fx[String]#λ]]
When I log implicits, I get:
[info] /home/nmrp3/devel/oss/xsd/src/main/scala/w3c/tests/CasterTest.scala:59: hlist.this.Mapped.hnilMapped is not a valid implicit value for shapeless.ops.hlist.Mapped[shapeless.HNil,[T]T => String] because:
[info] hasMatchingSymbol reported error: polymorphic expression cannot be instantiated to expected type;
[info] found : [F[_]]shapeless.ops.hlist.Mapped.Aux[shapeless.HNil,F,shapeless.HNil]
[info] (which expands to) [F[_]]shapeless.ops.hlist.Mapped[shapeless.HNil,F]{type Out = shapeless.HNil}
[info] required: shapeless.ops.hlist.Mapped[shapeless.HNil,[T]T => String]
[info] implicitly[Mapped[HNil, fx[String]#λ]]
It looks like the type lambda, bound to the T=>String type isn't getting lifted out to the whole expression to a T[_] prefix.
I can't see any reason why this should not work in principle. I've got a type of the right kind. fx[String]#λ is, for some definition of equivalent, equivalent to sx.
Have I hit a compiler bug, or am I missing something?
Matthew
--
Dr Matthew Pocock
Turing ate my hamster LTD
Integrative Bioinformatics Group, School of Computing Science, Newcastle University
skype: matthew.pocock
tel: (0191) 2566550