def read

yaml-for-bend@0.1.1.0 · yaml11.bend:233

import yaml-for-bend@0.1.1.0/yaml11.bend as Yaml11
import Base
import yaml-for-bend@0.1.1.0/value.bend as V
import yaml-for-bend@0.1.1.0/core.bend as C

233# A scalar's text read by a known tag, in its 1.1 forms: !!merge is the
234# merge key, "!" and !!str are a string.
235def read(+tag: String, +s: String) -> Result<&2, &2, String, V.Yaml>:
236  when(Result<&2, &2, String, V.Yaml>, Bool.or(Bool.or(String.eq(tag, "!"), String.eq(tag, C.yaml.tag("str"))), String.eq(tag, C.yaml.tag("merge"))), u => Done{V.Str{s}},
237    u => when(Result<&2, &2, String, V.Yaml>, String.eq(tag, C.yaml.tag("null")), u => C.must(Bool.pick(Maybe<&2, V.Yaml>, C.is_null(s), Some{V.Null{}}, None{}), "!!null", s),
238      u => when(Result<&2, &2, String, V.Yaml>, String.eq(tag, C.yaml.tag("bool")), u => C.must(bool.yaml(s), "!!bool", s),
239        u => when(Result<&2, &2, String, V.Yaml>, String.eq(tag, C.yaml.tag("int")), u => C.must(int.yaml(int.of(s)), "!!int", s),
240          u => C.must(float.yaml(float.of(s), int.of(s)), "!!float", s)))))

Uses (16)

Used by (1)