TestListActualMappedType mappedList, mappedList. Shapeless:
scala> val x = "foo"
x: String = foo
scala> implicitly[x.type =:= String]
<console>:13: error: Cannot prove that x.type =:= String.
implicitly[x.type =:= String]
^
, x.type String, shapeless.test.typed, :
import shapeless._, ops.hlist.Mapper
trait Person {
type Value
val v : Value
}
case class StringPerson() extends Person {
type Value = String
val v = "I like strings"
}
case class IntPerson() extends Person {
type Value = Int
val v = 42
}
trait lpvfun extends Poly1 {
implicit def default[A <: Person] = at[A](_.v)
}
object vfun extends lpvfun {}
val stringPerson = StringPerson()
val intPerson = IntPerson()
val testList = stringPerson :: intPerson :: HNil
val mappedList = testList map vfun
shapeless.test.typed[String :: Int :: HNil](mappedList)
, .
, , Mapper, , :
scala> val m = Mapper[vfun.type, StringPerson :: IntPerson :: HNil]
m: shapeless.ops.hlist.Mapper[vfun.type,shapeless.::[StringPerson,shapeless.::[IntPerson,shapeless.HNil]]]{type Out = shapeless.::[String,shapeless.::[Int,shapeless.HNil]]} = shapeless.ops.hlist$Mapper$$anon$5@6f3598cd
scala> implicitly[m.Out =:= (String :: Int :: HNil)]
res1: =:=[m.Out,shapeless.::[String,shapeless.::[Int,shapeless.HNil]]] = <function1>
, , , , .