Created
January 1, 2011 20:12
-
-
Save debasishg/761970 to your computer and use it in GitHub Desktop.
Lens can be generated from case classes through compiler plugins ..
This file contains hidden or 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
| scala> import scalaz._ | |
| import scalaz._ | |
| scala> import Scalaz._ | |
| import Scalaz._ | |
| scala> case class Address(no: Int, street: String, zip: String) | |
| defined class Address | |
| // this can be generated | |
| scala> val streetLens: Lens[Address, String] = Lens((a: Address) => a.street, (a: Address, s: String) => a.copy(street = s)) | |
| streetLens: scalaz.Lens[Address,String] = Lens(<function1>,<function2>) | |
| // similarly for other fields |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment