emit.bend checks
raw source on the hub · import yaml-for-bend@0.1.0.0/emit.bend as Emit
The emitter: values to YAML text, in block style, indented two spaces.
A string is plain when the Core schema reads it back as that string, and double-quoted otherwise. A sequence or mapping inside a sequence starts on the "- " line ("- - a", "- a: 1"). A key that is a collection is written after "? ". An empty collection is "[]" or "{}". A tag the schema knows is written "!!int", one starting "!" as it is, and any other "!<...>". load(dump(v)) is v for any value load returns.
3 imports
import Base import ./value.bend as V import ./core.bend as C
Types
type Pos source · line 19 · raw
Data
Where a node is written: at the start of a line, right after "- ", right after a key's ":" (or a tag), or as the later items of a collection, each on a line of its own.
LinePos
DashPos
ColonPos
MorePos
Definitions
def when source · line 25 · raw
@-A:Type -> @hit:Bool -> @yes:(@_:Unit -> A) -> @no:(@_:Unit -> A) -> A
def code source · line 32 · raw
@c:Char -> U32
def is_in source · line 37 · raw
@c:Char -> @s:String -> Bool
def hex.digit source · line 43 · raw
@+n:Nat -> Char
def hex.text source · line 47 · raw
@width:Nat -> @+n:Nat -> String
+n+ in +width+ hex digits.
def is_plain.char source · line 56 · raw
@+x:U32 -> Bool
What YAML may hold as it is: printable characters but the ones double quotes escape.
def escape.other source · line 60 · raw
@c:Char -> String
def escape source · line 70 · raw
@c:Char -> String
def escaped source · line 85 · raw
@s:String -> String
def quoted source · line 92 · raw
@s:String -> String
def all.plain source · line 95 · raw
@s:String -> Bool
def last.char source · line 102 · raw
@s:String -> Char
def first.char source · line 105 · raw
@s:String -> Char
def is_str source · line 108 · raw
@v:0x36754ca959c7683aed7402df6aa2fca0/value.Yaml -> Bool
def is_safe.plain source · line 118 · raw
@+s:String -> Bool
Whether +s+ reads back as itself when written plain: it isn't empty, has no blank at either end, starts with no indicator, holds no ": ", " #" or character that needs escaping, and the Core schema reads it as a string.
def str.text source · line 124 · raw
@+s:String -> String
def tag.text source · line 127 · raw
@+tag:String -> String
def spaces source · line 132 · raw
@n:Nat -> String
def lead source · line 137 · raw
@p:Pos -> @+ind:Nat -> String
What goes before a node's first line: indentation at a line's start, a break and indentation after a key, nothing after "- ".
def scalar.lead source · line 149 · raw
@p:Pos -> @+ind:Nat -> String
A scalar after its key gets a space; at a line's start, indentation.
def is_more source · line 160 · raw
@p:Pos -> Bool
def is_collection source · line 167 · raw
@v:0x36754ca959c7683aed7402df6aa2fca0/value.Yaml -> Bool
def scalar.text source · line 177 · raw
@v:0x36754ca959c7683aed7402df6aa2fca0/value.Yaml -> String
A scalar's text, or an empty collection's.
def is_tagged source · line 196 · raw
@v:0x36754ca959c7683aed7402df6aa2fca0/value.Yaml -> Bool
def emit source · line 204 · raw
@v:0x36754ca959c7683aed7402df6aa2fca0/value.Yaml -> @+ind:Nat -> @+p:Pos -> String
+v+ written at +p+, its lines indented +ind+.
def dump source · line 228 · raw
@v:0x36754ca959c7683aed7402df6aa2fca0/value.Yaml -> String
+v+ as a YAML document.
def dump.all source · line 232 · raw
@vs:List<&2, 0x36754ca959c7683aed7402df6aa2fca0/value.Yaml> -> String
Values as a stream of documents, each after "---".