Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Lenses Exercise #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/main/scala/monocle/LensExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ object LensHelper {
*
* {{{
* import monocle.Lens
* val strNumber = Lens[Address, Int](_.strNumber)(n => a => a.copy(strNumber = n))
* val streetNumber = Lens[Address, Int](_.strNumber)(n => a => a.copy(strNumber = n))
* }}}
*
* This case is really straightforward so we automated the generation of `Lenses` from case classes using a macro:
* {{{
* import monocle.macros.GenLens
* val strNumber = GenLens[Address](_.strNumber)
* val streetNumber = GenLens[Address](_.strNumber)
* }}}
*
* @param name lens
Expand All @@ -65,7 +65,6 @@ object LensExercises extends FlatSpec with Matchers with Section {
* }}}
*/
def exerciseGetAndSet(res0: Int, res1: Address) = {

streetNumber.get(address) should be(res0)
streetNumber.set(5)(address) should be(res1)
}
Expand Down Expand Up @@ -121,7 +120,6 @@ object LensExercises extends FlatSpec with Matchers with Section {
* }}}
*/
def exerciseComposeLens(res0: Int, res1: Person) = {

(addressLens composeLens streetNumber).get(john) should be(res0)
(addressLens composeLens streetNumber).set(2)(john) should be(res1)
}
Expand Down