Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
:: (Monad m, Ord k) | |
=> (NonEmpty k -> Maybe v -> m (Map k v, Map k v -> v)) | How to get and set the next Map from the possibly missing value. Passes in the path taken so far. |
-> NonEmpty k | |
-> Map k v | |
-> m (Maybe v, v -> Map k v) |
For a non-empty list of keys, iterate through the given Map
and return
the possibly missing value at the path and a function to set the value at
the given path and return the modified input Map
.
let obj = undefined -- { "a": { "b": { "c": 1 } } } (mValue, setValue) <- getPathLens doRecurse ["a", "b", "c"] obj print mValue -- Just 1 print (setValue 2) -- { "a": { "b": { "c": 2 } } }