def ex

bend-toon-codec@0.1.0.0 · src/expand.bend:184

import bend-toon-codec@0.1.0.0/src/expand.bend as Expand
import Base
import bend-toon-codec@0.1.0.0/src/json.bend as J

184# `acc` is the object under construction while walking a field chain, and
185# Done{JNil} while walking an array's elements.
186def ex(+j: J.Json, +acc: Result<&2, &2, String, J.Json>, +strict: Bool) -> Result<&2, &2, String, J.Json>:
187  match j:
188    case J.JObj{fs}:
189      ex(fs, init(), strict)
190    case J.JField{k, v, t}:
191      ex(t, fl.r(ex(v, init(), strict), segs_of(k), acc, strict), strict)
192    case J.JNil{}:
193      acc
194    case J.JArr{items}:
195      arr.r(ex(items, nil(), strict))
196    case J.JCons{h, t}:
197      cons.r(ex(h, init(), strict), ex(t, nil(), strict))
198    case _:
199      Done{j}

Uses (10)

Used by (1)