Reputation: 6490
I'm brand new to shapeless and I would like to transform a Mapper[mix.type, HNil]#Out
to a case class
How can I do this? (Let me know if you need more infos...)
Upvotes: 0
Views: 221
Reputation: 7768
That would only work if you define a case class that has the exact same shape that this Mapper#Out
. If that's the case, you can create an instance of your case class using shapeless.Generic
:
val mout = ... // HList coming from your Mapper
case class A(i: Int, s: String)
shapeless.Generic[A].from(mout): A
That's assuming Generic#Repr
and Mapper[mix.type, HNil]#Out
are the same type, which you can check using the following:
val mapper = the[Mapper[mix]]
val gen = the[Generic[A]]
implicitly[mapper#Out =:= gen#Repr] // This only complies if scalac can
// prove equality between these types
Upvotes: 1