I need a Fold (Map k v) (k, v)
optic. Is there a way to obtain it with the "optics" library? If not, is there one with "lens"?
Asked
Active
Viewed 65 times
2

oguz ismail
- 1
- 16
- 47
- 69

Nikita Volkov
- 42,792
- 11
- 94
- 169
1 Answers
3
In either optics
or lens
, you should be able to write:
pairs :: Fold (Map k v) (k, v)
pairs = folding Map.toList
Generally speaking folding
takes any function that produces a foldable result (in this case, a list of key-value pairs) and creates a fold over those elements.

K. A. Buhr
- 45,621
- 3
- 45
- 71