I hereby claim:
- I am yvendruscolo on github.
- I am yorggen (https://keybase.io/yorggen) on keybase.
- I have a public key ASDJQ4AZlhKlr9FQlguETvKkODjY6Xox0-ShNaE9beqXrwo
To claim this, I am signing this object:
{:linters {:defrule/hidden-flow {:level :error}} | |
:hooks {:analyze-call {clara.rules/defrule hooks.defrule/defrule}} | |
:lint-as {clara.rules/defrule clj-kondo.lint-as/def-catch-all | |
clara.rules/defquery clj-kondo.lint-as/def-catch-all}} |
(ns hooks.defrule) | |
(def clara-inserts | |
"The forms we care about, capable of inserting facts." | |
#{'insert! 'insert-all!}) | |
(def descend* | |
"Transducer to descend into inner forms, looling for those we care about, the ones that insert facts. | |
Unfortunately we can't really figure out if someone defines another function that calls `insert!`." | |
(comp (map macroexpand) |
(ns yvern.test-rules | |
(:require [clara.rules :refer [defrule insert!]] | |
[yvern.defrule :as check])) | |
(check/defrule | |
(defrule ok | |
[:a] | |
=> | |
(insert! {:fact-type :b}))) |
(ns yvern.defrule) | |
(def clara-inserts | |
"The forms we care about, capable of inserting facts." | |
#{'insert! 'insert-all!}) | |
(def descend* | |
"Transducer to descend into inner forms, looping for those we care about, the ones that insert facts. | |
Unfortunately we can't really figure out if someone defines another function that calls `insert!`." | |
(comp (map macroexpand) |
(defrule not-ok | |
[:a] | |
=> | |
(when (< 0.5 (rand)) | |
(insert! {:fact-type :b}))) |
(defrule overflow? | |
[?middle <- :middle] | |
[:or [?max <- :top] [?max <- :right]] | |
[:test (<= ($ ?max) ($ ?middle))] | |
=> | |
(insert! {:fact-type :overflow!})) | |
(defrule underflow? | |
[?middle <- :middle] | |
[:or [?min <- :bottom] [?min <- :left]] |
(ns yvern.hard-rule | |
(:require [clara.rules :refer [defrule insert!]])) | |
(def $ (comp val first)) | |
(defrule all-together | |
[?middle <- :middle] | |
[:or | |
[:and [?max <- :top] [?min <- :bottom]] | |
[:and [?min <- :left] [?max <- :right]]] |
(defmacro no-bangs! | |
[forms] | |
(if (->> forms | |
flatten | |
(filter symbol?) | |
(some (comp (partial re-find #"\!") name))) | |
(throw (ex-info "/(•̀o•́)ง No bangs!" {})) | |
forms)) | |
(no-bangs! |
(defmacro dont | |
[& _] | |
(throw (ex-info "(╯°□°)╯︵ ┻━┻" {}))) | |
(dont | |
(defn add [a b] (+ a b))) |
I hereby claim:
To claim this, I am signing this object: