Conversation

Focused transactional state updates: (%%=) :: Has (State s) sig m => Lens' s a -> StateC a m () -> m () lens %%= action = use lens >>= (`execState` action) >>= (lens .=) e.g.: _player %%= handleControls
3
4
1. handleControls only gets access to the player, not the rest of the state it’s drawn from. separation of concerns! 2. errors thrown in handleControls won’t result in incomplete state updates—the player is only updated if handleControls finishes successfully.
1
1
This Tweet is from a suspended account. Learn more
This Tweet is from a suspended account. Learn more
This Tweet is from a suspended account. Learn more
This Tweet is from a suspended account. Learn more