This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-17
Channels
- # aleph (57)
- # announcements (2)
- # babashka (11)
- # beginners (55)
- # calva (18)
- # cider (37)
- # clj-kondo (24)
- # clojure (18)
- # clojure-europe (80)
- # clojure-nl (2)
- # clojure-norway (22)
- # clojure-uk (7)
- # clojured (1)
- # clojurescript (24)
- # data-science (9)
- # datomic (45)
- # events (1)
- # gratitude (4)
- # humbleui (30)
- # hyperfiddle (7)
- # introduce-yourself (2)
- # malli (3)
- # missionary (12)
- # music (1)
- # off-topic (33)
- # re-frame (3)
- # reagent (11)
- # ring (24)
- # shadow-cljs (13)
- # sql (3)
- # tools-deps (4)
Hi guys! I'm learning hooks for a specific macro and I'm wondering what the best transformation for this kind of macro:
(f/match (my-fn)
[result] (str "OK ->" result)
[error] (str "KO ->" error))
Just a wrapper around merr/error
:
(defmacro match [tst & clauses]
(clojure.core/let [[result-vec result-form error-vec error-form] clauses
result-bind (result-vec 0)
error-bind (error-vec 0)]
`(clojure.core/let [res# ~tst]
(if-not (error? res#)
(clojure.core/let [~result-bind res#]
~result-form)
(clojure.core/let [~error-bind res#]
~error-form)))))
that's not the same. my-fn
returns some type that can be checked with error?
. kind of like if-let
, but for error?
oh, you were suggesting a macro hook? my apologies
lol i thought you were suggesting an alternative way to write the match
macro. a total misread on my part
Thanks @U04V15CAJ I have this:
(defn merr-match
[{:keys [node]}]
(let [[check-fn result-vec result-token error-vec error-token] (rest (:children node))
[result-sym] (:children result-vec)
[error-sym] (:children error-vec)
sym-destructured (api/vector-node [result-sym error-sym])
bindings (api/vector-node [sym-destructured check-fn])
body (api/vector-node [result-token error-token])
new-node (api/list-node
(list*
(api/token-node 'let)
bindings
body))]
{:node new-node}))
But seems binding is not correctly see in branch body (cf. screen). What I miss?hey y'all, I have a .clj-kondo/config.edn that uses :config-paths
, but it seems like this isn't respected in emacs. is there anything I need to do to get this working?
so if you have a path relative to the project root, you need to use "../config-dir"
if you have .clj-kondo/config.edn
oh I see, I was assuming I could include a filename in paths. I have {:config-paths ["../../.clj-kondo/common.edn"]}
look like i need to have directory structure like common/config.edn
that's got it working
thanks!