I'm not sure I understand the question. Can you edit to clarify the desired behavior?
There are 3 ways you can access deep data structures in the Tupelo library.
Using tupelo.forest to process tree-like data structures. See the docs and be sure to watch the video.
You can use tupelo.core/destruct, which is a fancier version of get-in using a template. See the examples here.
You can do a depth-first walk of your data structure, keeping track of the parents of each node using walk-with-parents. See the examples
and the docs.
Accessing the parents of a nested data element
You can do this using walk-with-parents and walk-with-parents-readonly. Consider this simple nested data structure:
(def data {:a 1 :b {:c 3}} )
We can walk the data structure, remembering the path from the root to each element. When we get to element 3, we have the following path of parent data:
(walk-with-parents data <noop-intc>) =>
:parents => [ {:a 1, :b {:c 3}} ; the orig map
[:b {:c 3}] ; the MapEntry for key :b
{:c 3} ; the map where value 3
[:c 3] ] ; the MapEntry with value 3
:data => 3
So the interceptor will be called with 2 args:
- a parents path vector of 4 elements
- the data item itself
For the -readonly variant the interceptor function can do validation & throw an exception if a problem is detected. For the non-readonly variant, the return value replaces the data element. Each interceptor is a 2-element map that looks like:
{:enter (fn [parents data] ...)
:leave (fn [parents data] ...) }
get-ininstead of threading macros.?, you have no way of knowing you are inside a map. You would have to keep track of the root + path, pass it down, decide from there what to do.