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

processing sub-lists #4

Open verdverm opened 2 years ago

verdverm commented 2 years ago

lists are hard to diff and such, but we should try some sort of implementation in the helpers

note, this is different from processing top-level lists

verdverm commented 2 years ago

For list processing on ops, use @list(and,or,index) defaults to and

op: {
  LD: [schema] @list() // process all RHS list elements with this one
  LA: [s1,s2] @list(and)  // op if all LHS elems unify with an elem of RHS
  LO: [s1,s2] @list(or) // op if any LHS elem unifies with an elem of RHS
  LP: [s1,s2,s3] @list(index) // pairwise unification, lists must be same length
}

Diff / Patch needs different processing, need a way to calc an index field, maybe @list(<index_field_name>)

How would this even be specified? We probably need an additional input like diff-cfg. Maybe some way to specify associative list once that proposal is implemented, but still need a config arg probably? Maybe there is decent default behavior? (prob just elem wise, stop once at end of one list) Maybe there is a short list of discriminator fields to match up (uuid, id, name), but they would need to be unique in both lists.