Skip to content

Commit

Permalink
clj-kondo: add missing sum-type hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
neshtea committed Jul 15, 2024
1 parent 65df24d commit a83574c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
:hooks {:analyze-call {active.clojure.monad/monadic hooks.monad/monadic
active.clojure.cljs.record/define-record-type hooks.record/define-record-type
active.clojure.cljs.record/define-singleton-type hooks.record/define-singleton-type
active.clojure.sum-type/define-sum-type hooks.sum-type/define-sum-type
active.clojure.record/define-record-type hooks.record/define-record-type
active.clojure.record/define-singleton-type hooks.record/define-singleton-type}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns hooks.sum-type
(:require [clj-kondo.hooks-api :as api]))

(defn define-sum-type
[expr]
(update expr :node
(fn [node]
(let [[sum-type-name predicate] (rest (:children node))]
(api/list-node
(list (api/token-node 'do)
(api/list-node [(api/token-node 'declare) sum-type-name])
(api/list-node [(api/token-node 'declare) predicate])))))))

0 comments on commit a83574c

Please sign in to comment.