def read
yaml-for-bend@0.1.1.0 · core.bend:144
import yaml-for-bend@0.1.1.0/core.bend as Core
import Base
import yaml-for-bend@0.1.1.0/value.bend as V
144
145
146def read(+tag: String, +s: String) -> Result<&2, &2, String, V.Yaml>:
147 when(Result<&2, &2, String, V.Yaml>, Bool.or(String.eq(tag, "!"), String.eq(tag, yaml.tag("str"))), u => Done{V.Str{s}},
148 u => when(Result<&2, &2, String, V.Yaml>, String.eq(tag, yaml.tag("null")), u => must(Bool.pick(Maybe<&2, V.Yaml>, is_null(s), Some{V.Null{}}, None{}), "!!null", s),
149 u => when(Result<&2, &2, String, V.Yaml>, String.eq(tag, yaml.tag("bool")),
150 u => must(Bool.pick(Maybe<&2, V.Yaml>, is_true(s), Some{V.Boolean{True{}}}, Bool.pick(Maybe<&2, V.Yaml>, is_false(s), Some{V.Boolean{False{}}}, None{})), "!!bool", s),
151 u => when(Result<&2, &2, String, V.Yaml>, String.eq(tag, yaml.tag("int")), u => must(int.yaml(int.of(s)), "!!int", s),
152 u => must(float.yaml(float.of(s), int.of(s)), "!!float", s)))))