I'm seeing rules no longer firing after I reloaded the namespace that contains them in the REPL, even if I create an entirely new session with (mk-session :cache false)
. What am I missing?
@tcarls might need a code example, numerous things could be happening, depending on the state of the namespace
@dadair, in hindsight, I'm pretty sure what's happening is caused by new defrecord
s being run, but trying to run rules against data from an atom that includes (expensive-to-calculate) cached previous instances of input data. Going to move the definitions into their own namespace; I expect that'll help.
@tcarls that is common
The potemkin
lib had some extensions to defrecord
and other related macros to avoid that sort of redefinition of classes to help with reloading workflows in the REPL
I think one workaround people do for Clara has been to do defrecord
in a separate ns that you don’t plan to reload much
So the rules don’t get mismatched definitions of the “same class”
One thing that's surprising me in using Clara is how one needs to take explicit steps to avoid getting two equal records created if arriving at the same fact via two different rules.
@tcarls yeah, there are pro’s and con’s to that
There are definitely use-cases where “cardinality” matters
I’ve had quite a few of those before. So if you “removed the duplicates” you’d fail to meet the needs of someone who wanted to count things
For whatever purpose
In Drools (popular Java-based rules engine), they went with “logical inserts” never are duplicated, but “unconditional inserts” are duplicated if they are not identical?
It was nice, when you really just didn’t want duplicates, but difficult to work with when you did
In Clara, if you need some “single count” fact in the end, you can just use an aggregation sort of rule
I do think it could be interesting if Clara had an options where it made working memory “set-like” and duplicates didn’t show up. There are definitely costs to doing this though.
headscratch
{:lhs [{:type pdfsort.types.Warning, :constraints [], :fact-binding :?warning}], :params #{}, :name "pdfsort.core/get-warnings"} is invalid or not included in the rule base.
...seems to be happening consistently for me right now when invoking code from lein run
, but not when invoking the same functions from Emacs/Cider.@tcarls where is the mk-session
you’re using (e.g., same ns as the rule? other ns?), and what does the function call look like?
and can you post a snippet of the rule?