Hi,
I was trying to use a custom fact-type-fn as explained in the docs, but I couldn't get it to work. I couldn't figure out what I was doing wrong, so I tried the example from the docs, like this:
(ns clara-test.core
(:require [clara.rules :as clara :refer :all]
[clara.tools.inspect :as inspect]))
(clara/clear-ns-productions!)
(defrecord IdHolder [id])
(defrule rule1
[[IdHolder "A"]]
=>
(println "this should be printed"))
(-> (mk-session :fact-type-fn (fn [fact]
(cond
(instance? IdHolder fact) [IdHolder (:id fact)]
:else (type fact))))
(insert (->IdHolder "A"))
fire-rules)
(defrule rule2
[IdHolder]
=>
(println "this actually is printed"))
(-> (mk-session)
(insert (->IdHolder "A"))
fire-rules)
The first one, using the custom fact-type-fn, does nothing, while the second print works fine (obviously). To me, it looks exactly like the example from the docs. Do I need something special in the insert maybe? Help would be very much appreciated!
I'm using clara version 0.21.0
thanks,
-Mathias