i trying learn shapeless(2.3.2). have created simple container 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 trying realise api method like:
def upsert[t](k: string, v: t) = ???
all of attemps finished compile errors like:
could not find implicit value parameter updater: shapeless.ops.record.updater[l,t shapeless.labelled.keytag[k.type,t]]
could please me understand how build such apis(not tightened shapeless) , how gather information solve such issues ?
i figured, i'd make comment answer, can accepted.
from experience working shapeless, when compiler complains missing implicit value, first thing try , provide relevant function via implicit parameter, if type in question shapeless. shapeless provides lots of implicits, , there chance adding implicit parameter fix such error.
in case, add updater
(not sure type parameters, should in line upd
) implicit parameter upsert
function.
Comments
Post a Comment