-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add clj-kondo hook for parallel let
plet
- Loading branch information
1 parent
658c429
commit 58103c1
Showing
2 changed files
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
resources/clj-kondo.exports/funcool/promesa/hooks/promesa.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(ns hooks.promesa | ||
(:require [clj-kondo.hooks-api :as api])) | ||
|
||
(defn plet | ||
;; this effectively rewrites the let to `(let [[bind1 bind2] [(expr-1) (expr-2)] ,,,) | ||
;; making referring to other binding syms produce an error | ||
;; thanks to @NoahBogart on Slack for this | ||
[{:keys [:node]}] | ||
(let [[_plet binds & body] (:children node) | ||
new-bind-syms (api/vector-node (take-nth 2 (:children binds))) | ||
new-bind-exprs (api/vector-node (take-nth 2 (rest (:children binds)))) | ||
new-node (api/list-node | ||
(list* (api/token-node 'clojure.core/let) | ||
(api/vector-node [new-bind-syms new-bind-exprs]) | ||
body))] | ||
{:node new-node})) |