Alch-Emi/elm-kdl/2.0.1

Kdl.Encode

Tools for turning Elm values into KDL values

Encoding Values

type alias Value =
Value

A KDL Value

These are the specific values used in argument and properties, like numbers and strings

string : String -> Value

Encode a String into a value

int : Int -> Value

Encode a integer into a value

float : Float -> Value

Encode a float into a value

rational : BigRational -> Value

Encode a BigRational into a value

bool : Bool -> Value

Encode a boolean into a value

null : Value

The value #null

Encoding Nodes

type alias Node =
String -> Node

A KDL Node, containing arguments, properties, and children

Notably, this representation of nodes does not contain their name, only their arguments, properties, and children. The name of the node will be encoded as part of the document. If you wish to track a node's name as well, use the type (String, Node).

emptyNode : Node

A node without arguments, children, or properties

nodeWithProps : (propType -> Value) -> List propType -> Node

Encode a node with properties, but no children or arguments

nodeWithArgs : (argType -> Value) -> Dict String argType -> Node

Encode a node with arguments, but no children or properties

node : List Value -> Dict String Value -> Document -> String -> Node

A fallback method for creating your own node encoders when you need a little more power.

Encoding Documents

emptyDocument : Document

A document with no nodes

document : List ( String, Node ) -> Document

Encode a document full of order-signifigant nodes

documentFromDict : (nodeType -> Node) -> Dict String nodeType -> Document

A document full of unique, order-insignifigant nodes