clj-kondo

Sam Ferrell 2025-02-19T21:34:33.801849Z

First time writing a hook... what's a decent way to rewrite something as (let [foo ???]) where the type of ??? is unknown

Sam Ferrell 2025-02-19T21:35:12.045949Z

All I want to achieve here is that foo is bound ... but not to be inferred as anything in particular

exitsandman 2025-02-19T21:36:21.522069Z

If I understand what you want to do, wrapping the right side in identity should do

Sam Ferrell 2025-02-19T21:37:51.013689Z

Oh I see that done elsewhere as well, common idiom?

Sam Ferrell 2025-02-19T21:39:09.930279Z

Is it (let [foo identity]) or (let [foo (identity ???)])

exitsandman 2025-02-19T21:39:24.006859Z

second one of course

Sam Ferrell 2025-02-19T21:39:41.120049Z

👍 that works thank you!

borkdude 2025-02-19T21:49:35.544719Z

Why do you want to expand in a let? You could also expand into (fn [foo]) perhaps, where the argument type is unknown

Sam Ferrell 2025-02-19T21:59:39.614559Z

Kind of just hacking on something to learn how to use it... could you tell me more about rewriting a node as a fn? Lets say I have...

(my-macro [foo :bar]
  (prn foo)) 
:bar is just some magic key that references something else far away... So I can rewrite this as... to at least have foo marked as a binding and being used
(let [foo (identity :bar)]
  (prn foo))
I'm not sure how I would rewrite it as (fn [foo] ...) instead

Sam Ferrell 2025-02-19T22:15:50.838429Z

Well I mean I know how to do it but not sure what it means to put an uncalled fn somewhere

borkdude 2025-02-19T22:17:50.405129Z

right, makes sense