~/bend-docscommunity

core.bend checks

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

The YAML 1.2 Core schema: how a scalar's text and tag become a value.

An untagged plain scalar is null (null, Null, NULL, ~ or nothing), a boolean (true/True/TRUE, false/False/FALSE), an integer (decimal, 0o octal, 0x hex), a float (decimal, .inf, -.inf, .nan) or else a string. A quoted or block scalar, or one tagged "!", is a string. A standard tag (!!str, !!null, !!bool, !!int, !!float) reads the text as that type, and fails when it can't; any other tag is kept as a Tagged value.

4 imports
import Base
import ./value.bend as V
import ./re.bend as R
import ./num.bend as N

Definitions

def yaml.tag source · line 18 · raw

@name:String -> String

def when source · line 21 · raw

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

def is_null source · line 28 · raw

@+s:String -> Bool

def is_true source · line 31 · raw

@+s:String -> Bool

def is_false source · line 34 · raw

@+s:String -> Bool

def dec.pat source · line 37 · raw

List<&2, 0x856d414a32087762da315b6efc605eaa/re.Pat>

def oct.pat source · line 40 · raw

List<&2, 0x856d414a32087762da315b6efc605eaa/re.Pat>

def hex.pat source · line 43 · raw

List<&2, 0x856d414a32087762da315b6efc605eaa/re.Pat>

def float.pat source · line 47 · raw

List<&2, 0x856d414a32087762da315b6efc605eaa/re.Pat>

[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?

def is_inf source · line 51 · raw

@+s:String -> Bool

def is_nan source · line 54 · raw

@+s:String -> Bool

def unsigned source · line 57 · raw

@s:String -> String

def is_neg source · line 70 · raw

@s:String -> Bool

def int.of source · line 74 · raw

@+s:String -> Maybe<&2, String>

An integer's decimal text, if +s+ is one.

def in.base source · line 81 · raw

@+s:String -> Bool

Whether +s+ is an integer in a base other than ten, which takes time that grows with the square of its length to read.

def float.of source · line 85 · raw

@+s:String -> Maybe<&2, String>

A float's text, if +s+ is one: as written, or ".inf", "-.inf", ".nan".

def or.int source · line 91 · raw

@m:Maybe<&2, String> -> @s:String -> @rest:(@_:Unit -> 0x856d414a32087762da315b6efc605eaa/value.Yaml) -> 0x856d414a32087762da315b6efc605eaa/value.Yaml

def or.float source · line 98 · raw

@m:Maybe<&2, String> -> @rest:(@_:Unit -> 0x856d414a32087762da315b6efc605eaa/value.Yaml) -> 0x856d414a32087762da315b6efc605eaa/value.Yaml

def plain source · line 106 · raw

@+s:String -> 0x856d414a32087762da315b6efc605eaa/value.Yaml

An untagged plain scalar.

def must source · line 112 · raw

@m:Maybe<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml> -> @+tag:String -> @+s:String -> Result<&2, &2, String, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

def int.yaml source · line 119 · raw

@m:Maybe<&2, String> -> Maybe<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

def float.yaml source · line 127 · raw

@m:Maybe<&2, String> -> @i:Maybe<&2, String> -> Maybe<&2, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

!!float: a float, or an integer written as one ("3" is 3.0).

def known source · line 140 · raw

@+tag:String -> Bool

The tags whose text the Core schema reads: "!", !!str, !!null, !!bool, !!int and !!float.

def read source · line 146 · raw

@+tag:String -> @+s:String -> Result<&2, &2, String, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

A scalar's text read by a known tag: "!" and !!str are a string, and !!null, !!bool, !!int and !!float must be one.

def read.or.keep source · line 155 · raw

@hit:Bool -> @+tag:String -> @+s:String -> Result<&2, &2, String, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

A tag that isn't known is kept with the text, as data: no tag runs code.

def tagged source · line 163 · raw

@+tag:String -> @+s:String -> Result<&2, &2, String, 0x856d414a32087762da315b6efc605eaa/value.Yaml>

A scalar with a tag.

def known.collection source · line 167 · raw

@+tag:String -> Bool

The tags that leave a collection as it is: "!", !!seq and !!map.

def collection.or.keep source · line 170 · raw

@hit:Bool -> @+tag:String -> @v:0x856d414a32087762da315b6efc605eaa/value.Yaml -> 0x856d414a32087762da315b6efc605eaa/value.Yaml

def collection source · line 178 · raw

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

A collection with a tag: another tag is kept with it, as data.