clara

http://www.clara-rules.org/
tcarls 2018-01-31T02:07:21.000198Z

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?

2018-01-31T04:45:28.000031Z

@tcarls might need a code example, numerous things could be happening, depending on the state of the namespace

tcarls 2018-01-31T16:11:55.000980Z

@dadair, in hindsight, I'm pretty sure what's happening is caused by new defrecords 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.

đź‘Ť 2
2018-01-31T16:12:53.000635Z

@tcarls that is common

2018-01-31T16:13:33.000129Z

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

đź‘Ť 1
2018-01-31T16:13:54.000406Z

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

2018-01-31T16:14:08.000539Z

So the rules don’t get mismatched definitions of the “same class”

tcarls 2018-01-31T22:19:10.000278Z

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.

2018-01-31T22:40:38.000082Z

@tcarls yeah, there are pro’s and con’s to that

2018-01-31T22:40:53.000298Z

There are definitely use-cases where “cardinality” matters

2018-01-31T22:41:16.000283Z

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

2018-01-31T22:41:23.000447Z

For whatever purpose

2018-01-31T22:42:01.000344Z

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?

2018-01-31T22:42:15.000267Z

It was nice, when you really just didn’t want duplicates, but difficult to work with when you did

2018-01-31T22:42:34.000006Z

In Clara, if you need some “single count” fact in the end, you can just use an aggregation sort of rule

2018-01-31T22:45:37.000093Z

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.

tcarls 2018-01-31T23:18:37.000066Z

headscratch

tcarls 2018-01-31T23:24:10.000242Z

{: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.

2018-01-31T23:33:18.000307Z

@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?

2018-01-31T23:33:42.000462Z

and can you post a snippet of the rule?