Open nivekuil opened 4 years ago
The suggestion seems reasonable to me. Let's see what @plexus thinks about it as well.
I think the reason we don't have custom print handlers is that elisp doesn't really have custom types. Even the common lisp style types are really just cons cells IIRC so it's hard to distinguish. But if we can offer custom print handlers in a way that makes sense then I'm all for it.
Having another look at this, I think it would be fair to provide an optional second argument to parseedn-print
and parseedn-print-str
which is an a-list
from symbol to printing function, where we dispatch on the first item in a list if it is a symbol. This would only cover the case where "custom" types are represented as a cons with a symbol "tag", but this is the most common way to do so in Elisp and it's what cl-struct
does (if I'm not mistaken).
A PR for that would be very welcome.
However for the issue that @nivekuil raised I think the actual problem is that while we parse inst and uuid (since they are part of the EDN spec) we don't print them correctly. I added printing for #inst
and #uuid
in #7 .
For
parseedn-read
, we can pass an alist of readers to convert e.g. #uuid into a string. Could this be done in the inverse operation,parseedn-print
, as well? Currently I've just patched it like so: