clj-yaml

lread 2023-09-11T19:03:31.994009Z

My first question in #yaml!: https://clojurians.slack.com/archives/C05KULJCC9G/p1694458919716179

Ingy döt Net 2023-09-11T19:25:28.034879Z

I wrote a bunch in #yaml but forgot to thread it

Ingy döt Net 2023-09-11T19:36:42.438529Z

> A bunch of things to say here 🙂 > > [12:16 PM] Let's start by avoiding useless quotes 🙂 >

recursive:
>   name: A node
>   child: &ref_node
>     name: Child node
>     child: *ref_node
> [12:18 PM] I thinking you meant "loader" instead of "parser" here. > In YAML parlance "load" means all the way from text to native. > "parse" is one stage of "load" > load = read->lex->parse->compose->resolve->contruct > [12:19 PM] parsing is the most difficult part to implement and the part we test the most. > this is you yaml parsed by 17 implementations: > https://play.yaml.io/main/parser?input=cmVjdXJzaXZlOgogIG5hbWU6IEEgbm9kZQogIGNoaWxkOiAmcmVmX25vZGUKICAgIG5hbWU6IENoaWxkIG5vZGUKICAgIGNoaWxkOiAqcmVmX25vZGU= > [12:21 PM] wrt recursive aliases, your example is completely valid and any loader should handle it (assuming the data model it loads to supports references and cyclic referencing) > [12:22 PM] YAML is a foremost a data serialization language. the opposite of load is "dump" > [12:23 PM] you should be able to dump any clojure data structure and later load back to an equivalent > [12:24 PM] this might involve configuring your dumper and loader to understand certain non-standard data structures. > [12:24 PM] but yaml is intended for that purpose, in a programming language agnostic manner >
[12:26 PM] $ perl -MYAML -E '$a = []; push @$a, $a; say YAML::Dump $a'
> --- &1
> - *1
> is a vector whose only element is a reference to itself >
[12:28 PM] $ perl -MYAML -E '$a = []; push @$a, $a; say Dump Load Dump $a'
> --- &1
> - *1
> and that's an example of re loading the dump and then dumping again 🙂 > [12:28 PM] that's all I can think of to say > [12:29 PM] @lee feel free to ask more questions. I'll even answer them in a thread 🙂

Ingy döt Net 2023-09-11T19:37:04.200589Z

That's from #yaml for all to see

lread 2023-09-11T20:31:48.632339Z

Join #yaml to pick Ingy's brain on YAML intricacies!

lread 2023-09-11T20:32:27.887769Z

(Well, they are intricate to this YAML noob anyway! simple_smile)