I’ve run into this problem a few times and haven’t found any standard solution, so I’m asking here.
For a specific example, imagine I have a list of pairs of words and their part of speech (I’m doing a natural language processing homework assignment), and I’d like to be able to, given a part of speech, look up the counts of the words I’ve encountered.
Is there an accepted solution? Any advice? A template haskell library that solves this for arbitrary depth maps (Hey, I can dream, can’t I)?
If a
Map (k1, k2) vis unsuitable (perhaps if you need to extract and manipulateMap k2 vs), then it’s not too hard to define composite Map manipulation functions. e.g.But I don’t know of any template haskell library to generate these functions for you, sorry.
EDIT Here’s my analogue of
insertWith: