From a83574c6be0109940c5095285860cb7d48141e05 Mon Sep 17 00:00:00 2001 From: Marco Schneider Date: Mon, 15 Jul 2024 14:35:10 +0200 Subject: [PATCH] clj-kondo: add missing sum-type hooks --- .../de.active-group/active-clojure/config.edn | 1 + .../active-clojure/hooks/sum_type.clj | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 resources/clj-kondo.exports/de.active-group/active-clojure/hooks/sum_type.clj diff --git a/resources/clj-kondo.exports/de.active-group/active-clojure/config.edn b/resources/clj-kondo.exports/de.active-group/active-clojure/config.edn index 8e2ea5e..f914e47 100644 --- a/resources/clj-kondo.exports/de.active-group/active-clojure/config.edn +++ b/resources/clj-kondo.exports/de.active-group/active-clojure/config.edn @@ -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}}} diff --git a/resources/clj-kondo.exports/de.active-group/active-clojure/hooks/sum_type.clj b/resources/clj-kondo.exports/de.active-group/active-clojure/hooks/sum_type.clj new file mode 100644 index 0000000..287fc76 --- /dev/null +++ b/resources/clj-kondo.exports/de.active-group/active-clojure/hooks/sum_type.clj @@ -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]))))))) +