asking for clarficiation here -- "on top of rewrite-clj" is a requirement, right?
not really no, just a means to an end
parcera doesn't have an existing layer that i know of, but round-tripping is an explicit goal so iiuc it does the preservation thing pretty well. i have used it for something where those things were important.
I don't see the benefit of parcera vs rewrite-clj for this
not making any claims about what's better, just bringing up options.
on a possibly relatede note, there is this interesting paragraph in the instaparse readme: > I find the hiccup format to be pleasant and compact, especially when working with the parsed output in the REPL. The main advantage of the enlive format is that it allows you to use the very powerful enlive library to select and transform nodes in your tree. https://github.com/Engelberg/instaparse#output-format
the reason i mention that is the so-called enlive format and the select / transform stuff.
parcera currently outputs to hiccup.
does parcera support the enlive format?
it's a todo-ish thing, but iiuc, hiccup can be converted to enlive format (and i presume the reverse is possible too).
someone in #off-topic suggested tools.reader could be patched to return ordered maps. I think I could support that in edamame, and just ignore whitespace/comments
cool
the use case is config files for glam (package manager): glam itself and the user should both be able to write to the config file
but I don't want to depend on the funky default ordering of clojure maps to write back
yes, that make sense
not sure i followed whether you were or were not going to try to support comment preservation.
I'm willing to drop that requirement, if it saves me hours of work
npm doesn't support it either
ah i see. i hope that if you do, you would eventually consider trying to support comments. i was going to say i really dislike not being able to put comments in package.json 😛
i think that's a json limitation iiuc
yep, they usually solve it by "comment": "hello"
yeah, much discussion like this: https://stackoverflow.com/questions/244777/can-comments-be-used-in-json
that isn't really a solution imo
anyway, this is off of the main point 🙂
One other solution I was considering: have one user.edn config and one machine.edn config and one config.edn which is the merged one of those two
But I don't think that's nice either
maybe I'll just have to bite the bullet and write the rewrite-cljc based lib
i wonder if one could use discard forms for commenting...
i think i see this in random source from time to time
i don't remember if rewrite-clj does discard stuff
it must
(lib/assoc node :b 1)
;; =>
(map-node ... children with child :b replaced with (token-node 1))
doesn't sound too difficult
yes, rewrite-cljc supports discard forms
ah, screw it, I'll start with the lib
lol
sorry
PRs welcome.
ha ha ha
well i have submitted a few in the past, right?
any suggestions for a name? rewrite-cljc-core-ops?
yes, you have, I'm grateful for your contribs :)
naming is hard...sorry no good ideas atm.
the use case would be merging EDN files while preserving formatting. edn-something could also work
rearrange-clj
rewrite-edn
😜
ah i like that one
ok
off to sleep -- good luck!
thanks!
have a good night sleep
@lee hmm, when I make a zipper of a map-node and then do z/root, I get back a forms node.
user=> (z/root (z/edn (p/parse-string "{:a 1}")))
<forms: {:a 1}>
I guess it makes sense
today I learned about node/coerce... I should probably include that in the clj-kondo hooks API. why hasn't anyone asked for this before :)
Fully qualify dep symbols in deps.edn: https://github.com/borkdude/rewrite-edn#examples
Ya, I think so. The forms node is an implicit do.
Cool, looking forward to studying this!
automatic coercion of metadata to metadata nodes is what caused me some grief when working with sci.
ok. but the hooks code will never see a metadata node
because clj-kondo already has processed them before (in the fork of rewrite-clj)
hmm
but coerce will indeed create one I guess
which is not what we want... ok , one good reason to not add it maybe
ya dunno really, just a thought for something to check