Created
December 10, 2016 15:02
-
-
Save tomverran/845d5841bb5ee1e06fb935478cea7380 to your computer and use it in GitHub Desktop.
shapeless-lenses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shapeless._ | |
import shapeless.syntax.singleton._ | |
import shapeless.labelled._ | |
case class Foo(name: String) | |
val f = LabelledGeneric[Foo] | |
case class Lens[O, K, V](get: O => V) | |
def mkLens[O, K <: Symbol, V](getter: O => V)(implicit lg: LabelledGeneric.Aux[O, FieldType[K, V] :: HNil], w: Witness.Aux[K]): Lens[O, K, V] = | |
Lens[O, K, V](getter) | |
mkLens({a: Foo => a.name}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment