Yamlw.y: def of cswap-bend-cli@0.1.0.0 Import: import cswap-bend-cli@0.1.0.0/fmt/yamlw.bend as Yamlw Lines 71-92 of cswap-bend-cli@0.1.0.0/fmt/yamlw.bend: https://jend.leeeet.dev/read.txt?path=cswap-bend-cli@0.1.0.0/fmt/yamlw.bend&start_line=71&end_line=92 import Base import cswap-bend-cli@0.1.0.0/json.bend as Json # `j` at the base indent `d` in context `k`. Chains (fields, items) carry their # lines at `d`; the first line of a chain starts wherever the caller left off. def y(j: Json.Json, +k: Ctx, +d: Nat) -> String: match j: case Json.JNull{}: lead(k) ++ "null" case Json.JBool{b}: lead(k) ++ Json.bool.show(b) case Json.JNum{t}: lead(k) ++ t case Json.JStr{s}: lead(k) ++ str(s) case Json.JArr{+items}: cont(is_nil(items), k, d, "[]", y(items, CChain{}, ind(k, d))) case Json.JObj{+fields}: cont(is_nil(fields), k, d, "{}", y(fields, CChain{}, ind(k, d))) case Json.JNil{}: "" case Json.JCons{h, +t}: "- " ++ y(h, CItem{}, d) ++ sep(t, d, y(t, CChain{}, d)) case Json.JField{key, v, +t}: str(key) ++ ":" ++ y(v, CKey{}, d) ++ sep(t, d, y(t, CChain{}, d)) Uses (12): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.append https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/fmt/yamlw.bend&name=Ctx https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/fmt/yamlw.bend&name=cont https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/fmt/yamlw.bend&name=ind https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/fmt/yamlw.bend&name=is_nil https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/fmt/yamlw.bend&name=lead https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/fmt/yamlw.bend&name=sep https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/fmt/yamlw.bend&name=str https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/json.bend&name=Json https://jend.leeeet.dev/definition.txt?path=cswap-bend-cli@0.1.0.0/json.bend&name=bool.show