acowley / yaml-light-lens

Lenses for working with YAML data.
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

Does this library support modification? #2

Open chrissound opened 6 years ago

chrissound commented 6 years ago

Hello! Thanks for making this!

I'm not too familiar with Lenses / lens, but willing to investigate further. Does this library support modification of a Yaml object / tree?

acowley commented 6 years ago

It does! You can see examples of this in the doctests in the haddocks, but looking now I notice a rather crucial missing ingredient: it looks like the yaml-light package doesn't offer a way to emit a YAML string! It sits on top of the HsSyck package, and offers a way to convert that package's YamlNode into a YamlLight value, but I don't see the reverse direction. I don't know if I'm just not finding the right thing now, or if it's never been there. If you look at the source of the function I linked, it seems hopeful that writing a function to go the opposite way wouldn't be too hard. Then you could call emitYaml on that and get back some YAML text.

I see that yaml-light has a repo, so if you want YAML text from your modified YAML object you could implement that function and open a PR there. If things are stuck there, we can add the necessary definition here as it seems a shame to not be able to save modified YAML values. (Evidently I only ever consume YAML documents in my own code.)