Copyright | (c) 2025 Patrick Brisbin |
---|---|
License | AGPL-3 |
Maintainer | pbrisbin@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Data.Aeson.Optics.Ext
Description
Documentation
atNth :: Int -> AffineTraversal' Value (Maybe Value) Source #
Adding shifts all later elements right:
>>>
['a', 'b'] & atNth 1 ?~ 'x'
['a', 'x', 'b']
Removing shifts all later elements left:
>>>
['a', 'b', 'c'] & atNth 1 .~ Nothing
['a', 'c']
NOTE: this function will also index objects, in which case this behaves
exactly like atKey
. This is necessary for our use-case and probably means
we could never upstream this.
>>>
{"0": 'a', "1": 'b'} & atNth 1 ?~ 'x'
{"0": 'a', "1": 'x', "2": 'b'}