def one.of

yaml-for-bend@0.1.1.0 · yaml.bend:48

import yaml-for-bend@0.1.1.0/yaml.bend as Yaml
import Base
import yaml-for-bend@0.1.1.0/token.bend as T
import yaml-for-bend@0.1.1.0/value.bend as V
import yaml-for-bend@0.1.1.0/compose.bend as C

48def one.of(r: Result<&2, &2, T.Error, List<&2, C.Doc>>) -> Result<&2, &2, T.Error, V.Yaml>:
49  match r:
50    case Fail{e}:
51      Fail{e}
52    case Done{ds}:
53      match ds:
54        case Nil{}:
55          Done{V.Null{}}
56        case Con{d, rest}:
57          match d:
58            case C.Doc{v, at}:
59              match rest:
60                case Nil{}:
61                  Done{v}
62                case Con{other, more}:
63                  match other:
64                    case C.Doc{w, second}:
65                      Fail{T.Error{"found a second document where load expects one; use load.all", second, T.Content{}}}

Uses (6)

Used by (1)