glaml
Types
A Document Error dispatched by yamerl.
It contains a string - msg
and a tuple of 2 integers - loc
.
The location is: #(line, column)
.
pub type DocError {
DocError(msg: String, loc: #(Int, Int))
}
Constructors
-
DocError(msg: String, loc: #(Int, Int))
pub type DocNode {
DocNodeNil
DocNodeStr(string: String)
DocNodeInt(int: Int)
DocNodeSeq(nodes: List(DocNode))
DocNodeMap(nodes: List(#(DocNode, DocNode)))
}
Constructors
-
DocNodeNil
-
DocNodeStr(string: String)
-
DocNodeInt(int: Int)
-
DocNodeSeq(nodes: List(DocNode))
-
DocNodeMap(nodes: List(#(DocNode, DocNode)))
pub type NodeGetError {
NodeNotFound(which: String)
InvalidSugar
}
Constructors
-
NodeNotFound(which: String)
-
InvalidSugar
Functions
pub fn get(
from node: DocNode,
to path: List(PathRule),
) -> Result(DocNode, NodeGetError)
Traverses the DocNode
and tries to find another DocNode
by matching the PathRule
s.
pub fn parse_file(path: String) -> Result(Document, DocError)
Parses the YAML file at path
and returns either Ok(Document(...))
or Error(DocError(...))
.
pub fn parse_string(string: String) -> Result(Document, DocError)
Parses the YAML string and returns either Ok(Document(...))
or Error(DocError(...))
.
pub fn sugar(
from node: DocNode,
to path: String,
) -> Result(DocNode, NodeGetError)
Does the same thing as get
but instead of a list of PathRule
s,
you write a String
that will get parsed into a list of PathRule
s for you.
Syntax
"some_key" == [Map("some_key")]
"#0" == [Seq(0)]
"combination.#0.of.these" == [Map("combination"), Seq(0), Map("of"), Map("these")]
// You can write as many dots as you want
"...test..#0." == [Map("test"), Seq(0)]