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

Guidance on working with reader macros #37

Open
martinklepsch opened this issue Nov 26, 2023 · 7 comments
Open

Guidance on working with reader macros #37

martinklepsch opened this issue Nov 26, 2023 · 7 comments

Comments

@martinklepsch
Copy link
Sponsor

martinklepsch commented Nov 26, 2023

Is it in scope for this lib to support transforms involving reader macros? I'm not sure how this would work so totally understand if it's out of scope :)

(require '[borkdude.rewrite-edn :as r])
(def z (r/parse-string "{:data {:foo #profile {:prod 1 :dev 2}}}"))
(r/get-in z [:data :foo]) ;-> <reader-macro: #profile {:prod 1 :dev 2}>
(r/assoc-in z [:data :foo :prod] false) ;-> NPE
@borkdude
Copy link
Owner

Show me how you would use get-in with normal EDN that contains a reader macro

@martinklepsch
Copy link
Sponsor Author

Show me how you would use get-in with normal EDN that contains a reader macro

Yeah I don't really know how that would work either 😅 I was just thinking of transforming aero configs using rewrite-edn so that's where that line of thinking is coming from...

@borkdude
Copy link
Owner

I don't know the answer either but would be happy to hear what you came up with :)

@martinklepsch
Copy link
Sponsor Author

Actually, thinking about this more, couldn't there just be a special way of "entering" the value behind the reader macro? I guess that's possible with rewrite-clj already... 💡 I think I just need dive into rewrite-clj a bit more :)

Feel free to close this :)

@borkdude
Copy link
Owner

Yes, I guess we could support that, e.g. (get-in [:foo :bar ?? :prod]) but what would go on the question marks?

@martinklepsch
Copy link
Sponsor Author

That's the question, isn't it? 😀 Maybe something like this?

(r/get-in [:foo :bar (r/reader-tag 'profile) :prod])

@borkdude
Copy link
Owner

I'd be willing to support that

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