Expand.ins: def of bend-toon-codec@0.1.0.0 Import: import bend-toon-codec@0.1.0.0/src/expand.bend as Expand Lines 108-125 of bend-toon-codec@0.1.0.0/src/expand.bend: https://jend.leeeet.dev/read.txt?path=bend-toon-codec@0.1.0.0/src/expand.bend&start_line=108&end_line=125 import Base import bend-toon-codec@0.1.0.0/src/json.bend as J import bend-toon-codec@0.1.0.0/src/head.bend as Hd # Insert `leaf` at `segs` inside `e`: an object value, a field chain, or # whatever sits at the path (then it conflicts unless the path has ended). def ins(+e: J.Json, +segs: List<&2, String>, +leaf: J.Json, +strict: Bool) -> Result<&2, &2, String, J.Json>: match e segs: case J.JObj{efs} Nil{}: same.pick(empty_obj(leaf), strict, e, leaf) case J.JObj{efs} Con{s, rest}: wrap.obj(ins(efs, segs, leaf, strict)) case J.JField{k, ev, t} Con{s, rest}: cell(Hd.keq(k, s), k, ev, t, ins(ev, rest, leaf, strict), ins(t, segs, leaf, strict)) case J.JNil{} Con{s, rest}: Done{J.JField{s, build(rest, leaf), J.JNil{}}} case J.JField{k, ev, t} Nil{}: Done{e} case J.JNil{} Nil{}: Done{e} case _ _: conflict(strict, segs, leaf) Uses (12): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=bend-toon-codec@0.1.0.0/src/expand.bend&name=build https://jend.leeeet.dev/definition.txt?path=bend-toon-codec@0.1.0.0/src/expand.bend&name=cell https://jend.leeeet.dev/definition.txt?path=bend-toon-codec@0.1.0.0/src/expand.bend&name=conflict https://jend.leeeet.dev/definition.txt?path=bend-toon-codec@0.1.0.0/src/expand.bend&name=empty_obj https://jend.leeeet.dev/definition.txt?path=bend-toon-codec@0.1.0.0/src/expand.bend&name=same.pick https://jend.leeeet.dev/definition.txt?path=bend-toon-codec@0.1.0.0/src/expand.bend&name=wrap.obj https://jend.leeeet.dev/definition.txt?path=bend-toon-codec@0.1.0.0/src/head.bend&name=keq https://jend.leeeet.dev/definition.txt?path=bend-toon-codec@0.1.0.0/src/json.bend&name=Json