
30 Apr
2013
30 Apr
'13
1:36 p.m.
On Tue, 30 Apr 2013 17:18:48 +0400 Nikita Volkov
Because of the above I have very often found myself in requirement for the following function:
withItem :: (Ord k) => k -> (Maybe i -> (r, Maybe i)) -> Map k i -> (r, Map k i) withItem k f m = let item = Map.lookup k m (r, item') = f item m' = Map.update (const item') k m in (r, m')
That's lens' At. http://hackage.haskell.org/packages/archive/lens/latest/doc/html/Control-Len...