clj-yaml

lread 2022-09-17T21:49:05.254209Z

@lee has joined the channel

2022-09-17T21:50:55.263369Z

@zulip-mirror-bot has joined the channel

logbot 2022-09-17T21:51:09.589419Z

@logbot has joined the channel

lread 2022-09-17T21:52:45.082179Z

set the channel topic: https://github.com/clj-commons/clj-yaml - YAML encoding and decoding for Clojure

borkdude 2022-09-17T21:54:52.224829Z

@borkdude has joined the channel

grzm 2022-09-17T21:55:05.849759Z

@grzm has joined the channel

lread 2022-09-17T21:55:47.781949Z

Heya, starting to feel like I’m bogging down your https://github.com/clj-commons/clj-yaml/pull/38 @grzm!

lread 2022-09-17T21:56:14.868739Z

Probably easier to discuss here than on a GitHub issue.

lread 2022-09-17T21:58:30.378009Z

I guess my main question is: do we really need/want to expose a snakeyaml constructor factory? My inclination is no.

grzm 2022-09-17T22:26:35.188979Z

No worries. I'm just busy and exhausted.

grzm 2022-09-17T22:29:08.238659Z

trying to think of how tags should be exposed. As meta is probably the easiest way (though not all Yaml node values can take meta). tagged-literals would be another possible way. Then then question is how to translate the tag representation to a tagged literal representation. And I don't know what round-tripping would look like.

lread 2022-09-17T22:29:15.186629Z

Thanks! When you have recharged your batteries (not before that), would love to chat.

grzm 2022-09-17T22:32:28.430759Z

I'm sympathetic to the idea of not exposing snakeyaml implementaiton details. That said, the current options are already not ideal: you can provide both :unsafe and :mark keyword args, but they're not really fully orthogonal. (I'm trying to look past my dislike for keyword args: that'd be a version 2 change I'd like to see)

lread 2022-09-17T22:35:28.901019Z

Good point about meta… hmmm…

lread 2022-09-17T22:37:11.060449Z

Well, get some good rest, and we can percolate on it.

grzm 2022-09-17T22:38:11.853879Z

I suppose we could change tagged nodes to a map with :clj-yaml/tag and :clj-yaml/value keys (namespaced to ensure disambiguation with the data itself)

lread 2022-09-17T22:40:07.877339Z

Oh that’s why :mark is optional… can’t do meta so it returns maps?

grzm 2022-09-17T22:40:09.592919Z

I'd like to see a full-on critique of EDN. Other serializations have such obvious flaws, but I'm sure I'm biased and blind to issues with EDN

grzm 2022-09-17T22:42:29.943869Z

re: :mark Oh, right. The examples in the README clearly show how the MarkedConstructor is supposed to be used. How'd I miss that?

lread 2022-09-17T22:42:35.871879Z

Oh… :mark wraps with with java class, same idea tho.

grzm 2022-09-17T22:42:52.154209Z

(apologies for the snark 😛)

lread 2022-09-17T22:43:23.923759Z

YAML is not a snark free zone. So snark away!

grzm 2022-09-17T22:46:03.742219Z

The map thing might be a way forward. Questions about how to only change the ones that would otherwise fail…prolly try/catch or something…

grzm 2022-09-17T22:47:00.043779Z

goes to get something to eat

lread 2022-09-17T22:48:32.396239Z

But wouldn’t a map be a breaking change?

grzm 2022-09-17T22:51:14.411809Z

Right now it just throws an exception with unknown tags, so (a) it's already broken and (b) any of this I'd see added as an option, like pass through but not throwing away anything.

lread 2022-09-17T22:54:54.024749Z

So if you’d enabled parsing unknown tags, you’d be in a different mode where maps are returned?

(parse-string "!!bad-tag 3" {:read-unknown-tags true})
Might return?

grzm 2022-09-17T22:56:30.929369Z

Something like that, yeah

lread 2022-09-17T22:57:54.924429Z

Maybe if we have an option where clj-yaml can return nodes instead of values? That might satisfy both :mark and :read-unknown-tags and also give you a richer return? I dunno, just throwing ideas out.

lread 2022-09-17T22:58:21.488089Z

(And nodes might be maps)

grzm 2022-09-17T22:59:46.545009Z

Or sequences. (Vectors/arrays)

lread 2022-09-17T23:01:33.304239Z

Forgetting about :mark for a sec, and round-tripping, another idea would be to return separate warnings/findings. Ex. {:type :unknown-tag :row x :col y}

grzm 2022-09-17T23:01:42.376459Z

I wouldn't want a generic node one. I'm not against it, but my use case is that tags are the exception, not the rule.

grzm 2022-09-17T23:02:14.035989Z

I just don't want the parser to bail if there's a tag

lread 2022-09-17T23:03:28.405569Z

Right. I guess we should step back and ask if it is important to know that an unrecognized tag was read. Round-tripping support would be one reason. As a user do you otherwise care?

lread 2022-09-17T23:08:34.320069Z

We can always have documented limitations. Fine with me if they are reasonable to clj-yaml users.

lread 2022-09-17T23:52:33.023519Z

Note: :mark result is currently not directly round-tripable:

(def x (parse-string "3" :mark true))
(generate-string x)
;; => "start: {line: 0, index: 0, column: 0}\nend: {line: 0, index: 1, column: 1}\nunmark: 3\n"

borkdude 2022-09-18T10:04:42.712219Z

@lee note that "don't bail on unknown tags" is the primary use case for the PR, which is just a feature coming over from another clojure library. That feature has been more or less directly ported. Since that feature worked fine in that other library, I was ok with the PR as is. To limit exposure, we could change that to a toggle or so, to behave the same as with the explicit :constructor.

borkdude 2022-09-18T10:11:36.837059Z

off-topic: I just had a "don't bail on unknown tags" problem for bb.edn https://github.com/borkdude/quickdoc/issues/19

lread 2022-09-18T16:02:46.296659Z

Cool, so sounds like knowing what tags were unknown doesn't have to be part of this particular issue.

borkdude 2022-09-17T21:58:02.305869Z

Thanks for creating this channel! I'll go to sleep now but when I come back, I'll read up.. 💤

❤️ 1
💤 1