Skip to content

Instantly share code, notes, and snippets.

@channingwalton
Created January 31, 2013 13:59
Show Gist options
  • Select an option

  • Save channingwalton/4683045 to your computer and use it in GitHub Desktop.

Select an option

Save channingwalton/4683045 to your computer and use it in GitHub Desktop.
Setting multiple values with lenses
def setL[T, A, B](la: Lens[T, A], lb: Lens[T, B])(a:A, b: B)(t: T): T = la.set(lb.set(t, b), a)
def setL[T, A, B, C](la: Lens[T, A], lb: Lens[T, B], lc: Lens[T, C])(a:A, b: B, c: C)(t: T): T = lc.set(setL(la, lb)(a,b)(t), c)
def setL[T, A, B, C, D](la: Lens[T, A], lb: Lens[T, B], lc: Lens[T, C], ld: Lens[T, D])(a:A, b: B, c: C, d: D)(t: T): T = ld.set(setL(la, lb, lc)(a,b, c)(t), d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment