~/bend-docscommunity

yaml.bend checks

raw source on the hub · import yaml-for-bend@0.1.1.0/yaml.bend as Yaml

YAML for Bend: read YAML text into values and write values back as YAML.

import ./yaml.bend as Y import ./value.bend as V

Y.load("a: [1, 2]") # Done{V.Mapping{[V.Entry{V.Str{"a"}, V.Seq{...}}]}}

load reads under the YAML 1.2 Core schema; load.v11 reads the YAML 1.1 types (yes/no booleans, 0 octal, base 60, timestamps, "<<" merges). Errors say what went wrong and where: T.error.show(e) is "mapping values are not allowed in this context at line 1 column 5".

6 imports
import Base
import ./token.bend as T
import ./parse.bend as P
import ./value.bend as V
import ./compose.bend as C
import ./emit.bend as E

Definitions

def when source · line 25 · raw

@-A:Type -> @hit:Bool -> @yes:(@_:Unit -> A) -> @no:(@_:Unit -> A) -> A

def doc.vals source · line 32 · raw

@ds:List<&2, 0x856d414a32087762da315b6efc605eaa/compose.Doc> -> List<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

def all.of source · line 41 · raw

@r:Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/compose.Doc>> -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml>>

def one.of source · line 48 · raw

@r:Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/compose.Doc>> -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

def sized source · line 68 · raw

@+lim:0x856d414a32087762da315b6efc605eaa/compose.Limits -> @+text:String -> @read:(@_:Unit -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/compose.Doc>>) -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/compose.Doc>>

A text past the size limit is refused before it is read.

def docs source · line 73 · raw

@+s:0x856d414a32087762da315b6efc605eaa/compose.Schema -> @+lim:0x856d414a32087762da315b6efc605eaa/compose.Limits -> @+text:String -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/compose.Doc>>

def load.all.with source · line 77 · raw

@s:0x856d414a32087762da315b6efc605eaa/compose.Schema -> @lim:0x856d414a32087762da315b6efc605eaa/compose.Limits -> @text:String -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml>>

Every document in +text+ under schema +s+, within limits +lim+.

def load.with source · line 82 · raw

@s:0x856d414a32087762da315b6efc605eaa/compose.Schema -> @lim:0x856d414a32087762da315b6efc605eaa/compose.Limits -> @text:String -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

The one document in +text+ under schema +s+, within limits +lim+: null when there is none, an error when there are more.

def load source · line 88 · raw

@text:String -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

The one document in +text+ under the YAML 1.2 Core schema, within the default limits: null when there is none, an error when there are more. A repeated key is an error.

def load.all source · line 92 · raw

@text:String -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml>>

Every document in +text+, under the Core schema.

def load.v11 source · line 96 · raw

@text:String -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

load, reading the YAML 1.1 types.

def load.all.v11 source · line 100 · raw

@text:String -> Result<&2, &2, 0x856d414a32087762da315b6efc605eaa/token.Error, List<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml>>

load.all, reading the YAML 1.1 types.

def limits source · line 107 · raw

0x856d414a32087762da315b6efc605eaa/compose.Limits

The default limits: C.Limits{size, depth, aliases, digits} with a text of at most 1048576 characters, collections nested at most 256 deep, aliases copying at most 100000 nodes into a document, and numbers in bases other than ten at most 1000 characters long.

def events source · line 112 · raw

@text:String -> 0x856d414a32087762da315b6efc605eaa/parse.Parsed

The events of +text+, as the parser emits them, and the error that ended them early, if one did. Flow collections nest at most 256 deep.

def dump source · line 116 · raw

@v:0x856d414a32087762da315b6efc605eaa/value.Yaml -> String

+v+ as YAML text in block style, which load reads back as +v+.

def dump.all source · line 120 · raw

@vs:List<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml> -> String

Values as a stream of documents, each after "---".