Core.enc: def of bend-schema-lib@0.4.1.0 Import: import bend-schema-lib@0.4.1.0/core.bend as Core Lines 1480-1543 of bend-schema-lib@0.4.1.0/core.bend: https://jend.leeeet.dev/read.txt?path=bend-schema-lib@0.4.1.0/core.bend&start_line=1480&end_line=1543 import Base def enc(s: Schema, x: Meaning(s)) -> Raw: match s x: case SNat{} n: RNum{n} case SNatIn{lo_, hi_} n: RNum{n} case SStr{} x: RStr{x} case SStrLen{lo_, hi_, s2} v: enc(s2, v) case SListLen{lo_, hi_, s2} v: enc(s2, v) case SOpt{i} None{}: RNull{} case SOpt{i} Some{v}: enc(i, v) case SOptional{i} None{}: RMissing{} # absent: the host writes no key where this one lands case SOptional{i} Some{v}: enc(i, v) case SList{e} Nil{}: RNil{} case SList{+e} h <> t: RCons{enc(e, h), enc(SList{e}, t)} case SField{n, fs, rest} Both{a, b}: RKey{n, enc(fs, a), enc(rest, b)} case SEnd{} Unit{}: REnd{} case SRule{s2, tag} v: enc(s2, v) case SStrict{s2} v: enc(s2, v) case STagged{k, n, cs, rest} Inl{a}: RKey{k, RStr{n}, enc(cs, a)} case STagged{k, n, cs, rest} Inr{b}: enc(rest, b) case STagEnd{k} e: Empty.absurd(Raw, e) case STrue{} Unit{}: RBool{True{}} case SBool{} b: RBool{b} case SEnum{names} x: RStr{x} case SVariant{n, vs, rest} Inl{a}: RKey{n, enc(vs, a), REnd{}} case SVariant{n, vs, rest} Inr{b}: enc(rest, b) case SVEnd{} e: Empty.absurd(Raw, e) case STuple{ts, rest} Both{a, b}: RCons{enc(ts, a), enc(rest, b)} case STEnd{} Unit{}: RNil{} case SJson{} value: RJson{value} case SInt{} i: int_raw(i) case SIntIn{lo_, hi_} i: int_raw(i) case SEither{l, r} Inl{a}: enc(l, a) case SEither{l, r} Inr{b}: enc(r, b) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Either https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Empty.absurd https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=bend-schema-lib@0.4.1.0/core.bend&name=Both https://jend.leeeet.dev/definition.txt?path=bend-schema-lib@0.4.1.0/core.bend&name=Meaning https://jend.leeeet.dev/definition.txt?path=bend-schema-lib@0.4.1.0/core.bend&name=Raw https://jend.leeeet.dev/definition.txt?path=bend-schema-lib@0.4.1.0/core.bend&name=Schema https://jend.leeeet.dev/definition.txt?path=bend-schema-lib@0.4.1.0/core.bend&name=int_raw