Fork me on GitHub
#clara
<
2017-10-14
>
mmer14:10:07

@zylox Thanks for the reply.

mmer15:10:27

Sorry another simple question - do all facts have to be records?

mikerod18:10:10

@mmer no. Clara allows for you to provide your own :fact-type-fn, for arbitrary “type dispatch”, as well as :ancestors-fn for setting up “type hierarchies”. This is all in much the same was as Clojure’s ad hoc hierarchies work via derive and isa? etc

mikerod18:10:26

By default, Clara uses clojure.core/type as to map a fact to type

mikerod18:10:42

and clojure.core/ancestors to determine the isa? style relationships

mikerod18:10:56

So changing nothing, you can use plain maps with :type metadata

mikerod18:10:31

(r/defrule my-rule
 [:my-fact-type (= (:x this) ?x)]
 =>
 (println "hello"))
(-> (r/mk-session [my-rule])
     (r/insert (with-meta {:x 10} {:type :my-fact-type}))
    r/fire-rules)