updateWorld
of @Changaco can still be improved. I'll show it gradually so you can see what's going on.
Firstly, we can eliminate duplication in case
statement and use lens composition to eliminate second over
:
quantity Polymorph = quantityPolymorph
quantity TeamPlayer = quantityTeamPlayer
quantity LoneWolf = quantityLoneWolf
updateWorld :: Fighter -> World -> World
updateWorld fighter w = increment (quantity fighter) w where
increment field = over (quantities . field) (+1)