Fork me on GitHub

Hi there - we're trying to use Clara in the REPL and having problems.... Specifically a REPL-run test that checks the output of a rule doesn't fail when that rule is redefined with errors, as if it is remembering the old rule. Restarting the REPL solves the problem, but wastes time and resources (memory in IntelliJ at least.) This suggests that a defrule can be re-evaluated in the repl and then clara will use the new version. However looking at the code suggests that rules are set statefully in an atom. It looks also as if that atom might be cleared using (clear-ns-productions!) (, - perhaps when this form is evaluated in the namespace in which the rule was defined? But in any case that didn't seem to help for us. Are we missing something obvious? What is the expected way? I could post further codes examples to reproduce etc but wanted to open discussion first. We are using Clara 0.20 🙂


@apbleonard are you using Clara in CLJ or CLJS?


CLJ - was just noticing that the stom is cljs ...


Yeah, in CLJ it’s simpler evaluation rules


when you use defrule it makes a var


and if you are using mk-session to automatically scan a namespace to find rule vars


they’ll linger if you remove them in a repl session from the source buffer


you can do something like typical clj idioms for removal if that’s the case, like (ns-unmap *ns* 'rule-name)

👍 3

if you redefine the rule with the same name - it’ll overwrite it though


also, you do not have to use Clara in a stateful/var oriented way


you can pass explicit rule/query structures to mk-session instead if that better suits your usage


Thanks so much for your help. We are clearly not misunderstanding how it should work .... It's still a problem for me .... but now I think the problem maybe our stateful test set up.


no problem


D'oh ... we'd reloaded the namespace containing the defrule, but not the namespace which was def-ing up a set of rules for a particular use-case, that was then passed to fire-rules further in. Simple as that picard-facepalm. Thanks a lot for your help though.

👍 3