This doesn’t tell me anything since getters/setters are almost useless in my experience.
This doesn’t tell me anything since getters/setters are almost useless in my experience.
Example: in a game you want to update the health points of all enemies that are affected by an area of effect attack. With lenses you would compose a lens from multiple simpler lenses:
```enemiesAtDistanceToPoint pos radius = enemies . filtered (distanceTo pos . (< radius))```
and then you could modify those enemies:
```enemiesAtDistanceToPoint (10,20) 5 . health -= 5```
The benefit here is that you abstract the work of extracting the enemies and can reuse it elsewhere. Also note the lack of any loop to affect multiple entities.
Filtering/selecting is big, but another interesting thing is that there are lenses (which I think are called prisms?) that only provide a view of something.
Eg you have a text document in Unicode, select all words marching a certain pattern, and then look as if they were encoded in ASCII. (No idea why this would useful :-) ).