Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What to do about empty sequences and mappings? #10

Closed
gvx opened this issue Nov 6, 2016 · 4 comments
Closed

What to do about empty sequences and mappings? #10

gvx opened this issue Nov 6, 2016 · 4 comments

Comments

@gvx
Copy link
Contributor

gvx commented Nov 6, 2016

I've been writing a Dumper that outputs data conforming to strictyaml, and in my testing of it's behaviour, I've found a problem: the only way to represent empty sequences and mappings in YAML is with flow style, which strictyaml disallows. I don't really know any way around making an exception for [] and {}, though, aside from just refusing to dump empty lists and dicts.

@crdoconnor
Copy link
Owner

Good question. How about this::

load("x:", Map({"x": Seq(Str())}) | EmptySeq())) == {"x": []}

load("x:", Map({"x": MapPattern(Str(), Str())}) | EmptyMap())) == {"x": {}}

@gvx
Copy link
Contributor Author

gvx commented Nov 6, 2016

I assume you mean

load("x:", Map({"x": Seq(Str()) | EmptySeq()})) == {"x": []}
load("x:", Map({"x": MapPattern(Str(), Str()) | EmptyMap()})) == {"x": {}}

? If so, I'm perfectly fine with emitting nothing for empty lists and dicts.

@crdoconnor
Copy link
Owner

crdoconnor commented Nov 6, 2016

oops, yeah that. I was anyway thinking of creating a null type and this is almost the same thing.

Let me ponder this for a day or so though before I implement though. I need to think through the implications.

@crdoconnor
Copy link
Owner

crdoconnor commented Nov 26, 2016

Still not sure if this is the best approach, but anyway: 58bba77 is released on version 0.3.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants