Emit.emit: def of yaml-for-bend@0.1.1.0 Import: import yaml-for-bend@0.1.1.0/emit.bend as Emit Lines 203-225 of yaml-for-bend@0.1.1.0/emit.bend: https://jend.leeeet.dev/read.txt?path=yaml-for-bend@0.1.1.0/emit.bend&start_line=203&end_line=225 import Base import yaml-for-bend@0.1.1.0/value.bend as V # +v+ written at +p+, its lines indented +ind+. def emit(v: V.Yaml, +ind: Nat, +p: Pos) -> String: match v: case V.Seq{xs}: match xs: case Nil{}: Bool.pick(String, is_more(p), "", scalar.lead(p, ind) ++ "[]\n") case Con{x, rest}: lead(p, ind) ++ "- " ++ emit(x, Nat.add(ind, 2n), Dash{}) ++ emit(V.Seq{rest}, ind, More{}) case V.Mapping{es}: match es: case Nil{}: Bool.pick(String, is_more(p), "", scalar.lead(p, ind) ++ "{}\n") case Con{V.Entry{+k, x}, rest}: when(String, is_collection(k) || is_tagged(k), u => lead(p, ind) ++ "? " ++ emit(k, Nat.add(ind, 2n), Dash{}) ++ spaces(ind) ++ ":", u => lead(p, ind) ++ scalar.text(k) ++ ":") ++ emit(x, Nat.add(ind, 2n), Colon{}) ++ emit(V.Mapping{rest}, ind, More{}) case V.Tagged{+tag, +x}: scalar.lead(p, ind) ++ tag.text(tag) ++ Bool.pick(String, is_collection(x), "", " ") ++ emit(x, ind, Bool.pick(Pos, is_collection(x), Colon{}, Dash{})) case _: scalar.lead(p, ind) ++ scalar.text(v) ++ "\n" Uses (19): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add 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=yaml-for-bend@0.1.1.0/emit.bend&name=Pos https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=is_collection https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=is_more https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=is_tagged https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=lead https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=scalar.lead https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=scalar.text https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=spaces https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=tag.text https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/emit.bend&name=when https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/value.bend&name=Entry https://jend.leeeet.dev/definition.txt?path=yaml-for-bend@0.1.1.0/value.bend&name=Yaml