Skip to content

Instantly share code, notes, and snippets.

@milessabin
Created June 10, 2012 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milessabin/2905994 to your computer and use it in GitHub Desktop.
Save milessabin/2905994 to your computer and use it in GitHub Desktop.
Solution for @aloiscochard
// Internal function
def update[L1 <: HList, L2 <: HList](k: Key, fs: L1)(ts: L2 => L2)(implicit e: CoNatTRelAux[L1, Field, L2, Id])
// Function used by client
def update[P1 <: Product, P2 <: Product, L1 <: HList, L2 <: HList, F](k: Key)(fs: P1)
(implicit
h1: HListerAux[P1, L1],
e: CoNatTRelAux[L1, Field, L2, Id],
h2: HListerAux[P2, L2],
t: TuplerAux[L2, P2],
unhl : FnUnHListerAux[L2 => P2, F],
hl : FnHListerAux[F, L2 => P2]) =
new Update[L1, L2, P2, F](k, fs.hlisted)
class Update[L1 <: HList, L2 <: HList, P2 <: Product, F](k: Key, fs: L1)
(implicit
hl : FnHListerAux[F, L2 => P2],
h2: HListerAux[P2, L2],
e : CoNatTRelAux[L1, Field, L2, Id]) {
def to(ts: F) = {
val hts = (l2 : L2) => (ts.hlisted(l2).hlisted)
update(k, fs)(hts)(e)
}
}
// USED THAT WAY
update(c.key)(key, name).to((a, b) => (a, b + "*"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment