I'm very new to shapeless and struggling to derive a Tupler for my HList. Here is a simplified example:
object Builder {
import shapeless.ops.hlist.Tupler.hnilTupler
val empty: Builder[HNil] = new Builder[HNil](HNil)
}
class Builder[L <: HList: Tupler](list: L) {
def add[T](value: T): Builder[T :: L] = new Builder[T :: L](value :: list)
def tuple: Tupler[L]#Out = list.tupled
}
The line def add[T](value: T): Builder[T :: L] = new Builder[T :: L](value :: list) doesn't compile since there is no implicit Tupler[T :: L] and I cannot figure out to derive the next one from the previous one.
Any thoughts?
shapeless.ops.hlist.Tupler.hnilTupleris not supposed to be imported.Normally in Scala, if a method lacks some implicit, you add corresponding implicit parameter. Try