hofstadter-io / cuetils

CLI and library for diff, patch, and ETL operations on CUE, JSON, and Yaml
BSD 3-Clause "New" or "Revised" License
78 stars 6 forks source link

How might an operator be defined as a recursive structure? #33

Open verdverm opened 2 years ago

verdverm commented 2 years ago

Creating an issue to capture the later thought in #32

How could we define an operator input, such that it applies recursively to a tree which is itself recursive?

a tree:

name: "a1
val: 0
children: [{
  name: "b1"
  val: 0
  children: [ { name: "c1", val: 0 }]
},{  
  name: "b2"
  val: 0
  children: [ { name: "c2", val: 0 }]
}]

the desired pick per node would produce the tree with just names

name: string
children: <...>?
verdverm commented 2 years ago

If we specify the "recursion field" like children above, then we ought to be able to mutually recurse on Pick and target, while recursing on the field to reset context, with something like a PickR that moves us down the recursive structure