The traverse lens (is it a lens?) allows looking at Map key value in a value-by-value basis. For example:
import Data.Map
import Control.Lens
simpleMap :: Map Int Char
simpleMap = fromList [(1, 'a'), (2, 'b')]
nextCharAll :: Map Int Char -> Map Int Char
nextCharAll = traverse %~ succ
nextCharAll simpleMap is fromList [(1, 'b'), (2, 'c')].
What kind of traversal/lens can I use to do something like the following?
nextIntNextChar :: Map Int Char -> Map Int Char
nextIntNextChar =
asKeyValuePairs
. (_key %~ (+1))
. (_value %~ succ)
I'm not sure if you like it, but one of the ways is to convert it to a list back and forth with
Iso.