You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to call this like mupdate (insert bar baz) foo.
Maybe with upsert from #809 it will be also acceptable --- just upsert (insert bar baz . fromMaybe mempty) foo or even there is a perfect way using currently implemented functionality, but I can't see them.
P. S. of course, this can be easily done throw non from lens, but lens are not always advisable
The text was updated successfully, but these errors were encountered:
Maybe you want insertWith union foo (singleton bar baz)?
> f a b c = insertWith union a (singleton b c)
> :t f
f :: (Ord k1, Ord k2) => k1 -> k2 -> a -> Map k1 (Map k2 a) -> Map k1 (Map k2 a)
> f "0" "1" "2" mempty
fromList [("0",fromList [("1","2")])]
> f "0" "1" "2" $ singleton "0" mempty
fromList [("0",fromList [("1","2")])]
> f "0" "1" "2" $ singleton "0" $ singleton "1" ""
fromList [("0",fromList [("1","2")])]
Maybe, I'm doing something wrong, but this combination is very frequent in my programms. Imagine we have some nested map
and we want to insert a value
baz
to thebar
offoo
. I think it would be nice to have something liketo call this like
mupdate (insert bar baz) foo
.Maybe with upsert from #809 it will be also acceptable --- just
upsert (insert bar baz . fromMaybe mempty) foo
or even there is a perfect way using currently implemented functionality, but I can't see them.P. S. of course, this can be easily done throw
non
from lens, but lens are not always advisableThe text was updated successfully, but these errors were encountered: