This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-04
Channels
- # aleph (1)
- # asami (6)
- # babashka (44)
- # beginners (20)
- # calva (6)
- # circleci (1)
- # clj-kondo (2)
- # cljdoc (2)
- # clojure (184)
- # clojure-europe (13)
- # clojure-nl (4)
- # clojure-spain (1)
- # clojure-uk (4)
- # clojurescript (35)
- # code-reviews (1)
- # conjure (3)
- # core-async (60)
- # core-logic (1)
- # cursive (11)
- # data-science (2)
- # events (11)
- # graalvm (4)
- # graphql (2)
- # introduce-yourself (1)
- # jobs (2)
- # leiningen (3)
- # malli (16)
- # minecraft (6)
- # practicalli (1)
- # reagent (3)
- # reitit (1)
- # releases (3)
- # remote-jobs (2)
- # rewrite-clj (21)
- # shadow-cljs (12)
- # tools-deps (21)
- # vim (16)
Morning folks, and happy new year….
I’ve spent my christmas break exploring rewrite-clj. It looks really cool and has helped me to finally understand zippers. Kudos on all the project docs. They’ve been really helpful.
I’m wondering how you’d go about determining whether some zloc that has been navigated to is a string. My first thought was to say (string? (zip/node zloc))
but that doesn’t work because my string is a token.
Then I found node/value
which seems to return the string but is marked as deprecated.
I tried following the advice in the deprecation node but both node/child-sexprs
and node/children
are coming out as nil.
Glad you found the docs helpful. Always looking to improve them. Let us know if anything was amiss/confusing.
Yeah but the problem is that sexpr seems to return strings even for map nodes. The bigger picture is that I’m using this to edit a json tree and need to isolate my edits to strings in the rhs position of any maps (i.e. leave the keys alone).
https://cljdoc.org/d/rewrite-clj/rewrite-clj/1.0.699-alpha/api/rewrite-clj.zip#sexpr
although you're speaking about JSON. rewrite-clj is intended to be used on clojure code... JSON...?
Yeah but it comes with a zipper that works well with a variety of data-types. The ones in core work only seem to work if the entire data-structure is built out of the same collection type
If there’s something else you’re aware of that’s better for editing JSON trees I’d be pleased to discover alternatives. (it=rewrite-clj)
if rewrite-clj accepts JSON then that might be accidental, I would not expect that to work at all
ok, yes, that should work 😅 you might also be interested in https://github.com/borkdude/rewrite-edn which is a thin layer over rewrite-clj
There have been some ideas floating around to make a more elaborate version of tag
that returns :string
etc and not only :token
, which I think should be a good solution in general. I've been making my own predicates in clj-kondo for this.