I am trying to learn Shapeless(2.3.2). I have created a very simple container for extensible records:
case class Records[L <: HList](ps: L) {
def get(k: Witness)(implicit selector: Selector[L, k.T]): selector.Out = selector(ps)
def rm[V, Out <: HList](k: Witness)(implicit remover: Remover.Aux[L, k.T, (V, Out)]) =
this.copy(ps = remover(ps)._2)
def upd[F](f: F)(implicit updater: Updater[L, F]) = this.copy(ps = updater(ps, f))
}
Now I am trying to realise API method like:
def upsert[T](k: String, v: T) = ???
All of my attemps are finished with compile errors like:
could not find implicit value for parameter updater: shapeless.ops.record.Updater[L,T with shapeless.labelled.KeyTag[k.type,T]]
Could you please help me to understand how to build such APIs(not tightened to shapeless) and how to gather information to solve such issues ?
upsert, as you've done with theupd. That's a general rule of thumb with shapeless: if it asks for a implicit value, try adding it as implicit parameter to relevant function. - Haspemulator