Skip to content

Commit 7f3acbc

Browse files
Clarify the lens exercise description (#2092)
* Clarify the lens exercise description This PR improves the Lens exercise description in two ways: 1. Expand the description a bit to convey _why_ updating nested records are annoying 2. Remove direct reference to Haskell, as this is intended as a generic description * Update exercises/lens-person/description.md Co-authored-by: Erik Schierboom <[email protected]> * Change text to have one sentence per line Co-authored-by: Erik Schierboom <[email protected]>
1 parent 472204b commit 7f3acbc

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

exercises/lens-person/description.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
Use lenses to update nested records (specific to languages with immutable data).
44

5-
Updating fields of nested records is kind of annoying in Haskell. One solution
6-
is to use [lenses](https://wiki.haskell.org/Lens). Implement several record
7-
accessing functions using lenses, you may use any library you want. The test
8-
suite also allows you to avoid lenses altogether so you can experiment with
9-
different approaches.
5+
Updating fields of nested, immutable records is kind of annoying.
6+
The code for such cases is as cumbersome as the structure is deep.
7+
If you have, say, a Person, that contains an Address, which has a Street, that has a Number, updating the Number requires creating a new Street with the new Number, then a new Address with the new Street and, finally, a new Person with the new Address.
8+
Confused already?
9+
10+
One solution to this problem is to use [lenses](https://en.wikibooks.org/wiki/Haskell/Lenses_and_functional_references).
11+
12+
Implement several record accessing functions using lenses.
13+
The test suite also allows you to avoid lenses altogether so you can experiment with different approaches.

0 commit comments

Comments
 (0)