This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-01
Channels
- # aleph (71)
- # aws (1)
- # bangalore-clj (4)
- # beginners (36)
- # boot (153)
- # cider (23)
- # clara (9)
- # cljs-dev (67)
- # cljsjs (2)
- # cljsrn (22)
- # clojure (348)
- # clojure-argentina (4)
- # clojure-austin (12)
- # clojure-berlin (9)
- # clojure-dusseldorf (6)
- # clojure-france (4)
- # clojure-italy (4)
- # clojure-russia (358)
- # clojure-spain (2)
- # clojure-spec (28)
- # clojure-uk (109)
- # clojurescript (130)
- # core-typed (1)
- # cursive (35)
- # datascript (6)
- # datomic (18)
- # emacs (12)
- # hoplon (4)
- # klipse (64)
- # lein-figwheel (13)
- # leiningen (3)
- # luminus (4)
- # lumo (51)
- # mount (22)
- # off-topic (83)
- # om (22)
- # om-next (8)
- # onyx (3)
- # pedestal (8)
- # perun (6)
- # portland-or (2)
- # re-frame (50)
- # ring (8)
- # ring-swagger (5)
- # untangled (10)
- # yada (9)
@apbleonard Think of it as clara.rules/mk-session
accepts any number of “rule sources”. This can be anything that implements the clara.rules.compiler/IRuleSource
protocol or just a collection of rule/query structures.
Clojure’s Symbol implements the clara.rules.compiler/IRuleSource
protocol. The function to implement is clara.rules.compiler/load-rules
which must return a collection of rule/query structures.
However, Will had a good example if all you want to do is something simple like pass rules in
(defrule one-rule <etc>)
(defrule another-rule <etc>)
(defquery some-query <etc>)
;;;; Make session
(mk-session [one-rule another-rule some-query])
you can also mix and match. Symbol
implements IRuleSource
by expecting the symbol to resolve to a namespace name. It scans the whole namespace and finds all rules/queries in vars of that namespace.
@mike1452 Will mentioned that records allow you to refer to record fields directly in the rule. For non-records, you can use destructuring though. Just so you kmow
(defrule my-rule [:my-type-thing [{:keys [x y]}] (= x “hello”)]
<etc>)
thanks