by ozataman · 13y ago · 0 comments
over (location.x) (+ 10) $ player1
"over location's x, add 10"
player1 & location.x .~ (+10)
format which has a nice scansion.Broadly, you wouldn't want to do that because it implies mutation. There's not much value in `player1.location.x %~ (+10)` because it can't modify player1... just return a modified (player1'new).
Of course, stateful mutation is just a monadic effect, so you can wrap it up into a State monad, which Lens already has shortcuts for
do
location.x += 10
location.y += 10
which has type like `MonadState ThingWithLocation m => m ()` and we can then apply it to whatever `player` we want as a pure function.