clara

http://www.clara-rules.org/
dominicm 2018-05-17T12:01:48.000308Z

I'm trying to figure out Clara with tuples, partially as I've been brainwashed by Datomic, and partially because I think I like the independence. Precept looks like it's covered a lot of the work for that, any reason I couldn't use it as a general purpose library?

dominicm 2018-05-17T12:12:41.000235Z

It's more than possible I should convert the tuples into maps or something, but I'm entirely uncertain.

2018-05-17T12:38:51.000184Z

@dominicm @alex-dixon is the Precept guru. Clara lets you configure the sort of facts it can work with if you want to do something like tuples. Some of this is explained in http://www.clara-rules.org/docs/fact_type_customization/

2018-05-17T12:39:13.000017Z

If precept is using tuples already, could look there for example too.

dominicm 2018-05-17T12:41:45.000151Z

I did the type customisation for a tuple, it's working out okay, however my rules are full of a lot of destructuring sugar:

(defrule app-asg-min-size
  [:box/type [[e a v]] (= v :server) (= ?app e)]
  [?tup <- :min-size [[e a v]] (= e ?app)]
  =>
  (let [[e a v] ?tup]
    (insert!
      [(str e "-asg") :min-size v])))

dominicm 2018-05-17T12:42:45.000534Z

precept does seem to have something to allow queries like this one:

(rule todo-is-visible
  [[_ :visibility-filter :active]]
  [[?e :todo/done false]]
  =>
  (println "The todo with this entity id is visible: " ?e)

dominicm 2018-05-17T12:43:02.000586Z

I should probably just try it and see what happens šŸ˜›

dominicm 2018-05-17T13:35:10.000608Z

It doesn't seem that precept supports newer clara versions, a shame.

2018-05-17T13:41:31.000505Z

@dominicm I am not aware of anything in a newer clara that broke Precept. Thatā€™d be a bit of a surprise to me. Alex has generally been pretty active in the Clara changes etc. hmm.

2018-05-17T13:43:50.000292Z

As far as the syntactic overhear you mentioned. I think you may be right there. Precept May have defined its own syntax later with something like a macro and then just generated Clara rule forms from it. Not sure. Iā€™d have to check there as well.

2018-05-17T13:44:23.000346Z

Are you wanting to have it look more like a datalog sort of query I guess?

dominicm 2018-05-17T13:47:12.000507Z

@mikerod I can report the bug to Precept, if they will be interested. It would certainly suit my data format better if I did that. I don't think I'm really utilising the "rule type" concept very much. I'm trying to figure out if I can coerce my facts into maps that would be more like what Clara expects, but I'm not sure the type would be more useful there either.

dominicm 2018-05-17T13:49:29.000418Z

@mikerod in case you're interested https://github.com/CoNarrative/precept/issues/115

2018-05-18T10:15:04.000227Z

CompilerException java.lang.IllegalArgumentException: Can't define method not in interfaces: insert_facts_BANG_, compiling:(precept/listeners.cljc:14:1) 
I believe the protocol method signature there changes in 0.18.0 so thatā€™s probably it without looking at the code at the moment. It should be an easy uplift though since the new info passed was a superset of the previous (i.e. arguments were added not removed). Iā€™ll comment on the Precept issue later. @dominicm

dominicm 2018-05-18T10:30:14.000497Z

yeah, didn't seem like it would be terrible to fix, but I have no context šŸ™‚

2018-05-17T13:54:33.000070Z

Thatā€™s strange. I wonder if Alex will give some feedback on that one soon. I guess to mess with precept for now just use the version it has declared.

2018-05-17T13:54:52.000552Z

Iā€™ll check that out In a few. Not at laptop at the moment.

2018-05-17T13:57:05.000256Z

Yeah it is convenient to model data the same as Clara built in. But not necessary of course. Also making a simpler DSL to interact wouldnā€™t be too hard potentially.

2018-05-17T13:57:44.000883Z

For tuples. You could make a record type for them that just had an e, a, v fields. Then youā€™d get more concise Clara syntax at least

alex-dixon 2018-05-17T14:12:38.000755Z

@dominicm Hey. I havenā€™t tried upgrading to 18 yet but there were some breaking changes in 17 that were addressed in this branch https://github.com/CoNarrative/precept/pull/113

šŸŽŠ 1
alex-dixon 2018-05-17T14:16:30.000397Z

@dominicm Is there something in particular in 0.18.0 that youā€™re interested in having? Iā€™ve been out of the loop

alex-dixon 2018-05-17T14:22:44.000158Z

@mikerod Iā€™ve been thinking about the roles/responsibilities of libraries like Precept vs. the Clara core. Iā€™d like the devtools Iā€™ve been working on to be compatible with Clara, but Iā€™m somewhat uncomfortable with thinking of that being part of the core, so I was wondering about the groupā€™s thoughts on revitalizing something like clara.tools to house things like that

2018-05-17T14:27:45.000147Z

@alex-dixon to me it made sense to have it be a separate library like the clara.tools concept

alex-dixon 2018-05-17T14:28:03.000414Z

Now that dominic brings it up, Iā€™m also curious whether Clara would be interested in a Datalog syntax implementation. And yesā€¦I might have asked this a year ago but thereā€™s reasons I didnā€™t. Namely I didnā€™t know Clojure at the time, hadnā€™t really contributed at all to open source, and like now Iā€™m sort of intimidated by Claraā€™s codebase and not that confident in my ability to work efficiently in it

šŸ‘ 1
dominicm 2018-05-17T14:28:05.000147Z

@alex-dixon no idea, I just picked latest and started there.

dominicm 2018-05-17T14:28:35.000647Z

Datomic syntax for clara in an isolated library would be nice, from a total beginner's pov.

2018-05-17T14:29:11.000544Z

@alex-dixon It doesnā€™t have to be in that same repo though really unless you had particular reasoning for that. I havenā€™t had a chance to look at the devtools stuff that was discussed here the other day. It sounded interesting though

2018-05-17T14:33:02.000319Z

> Datomic syntax for clara in an isolated library would be nice, from a total beginnerā€™s pov. I agree that that sounds cool

2018-05-17T14:33:33.000680Z

Probably would be applicable to people in the clj-ecosystem looking into Clara too if that was the sort of data models they were already using. Interesting if Precept already has that layer implemented

alex-dixon 2018-05-17T14:35:45.000127Z

The devtools were conceived in isolation, so before Iā€™d work on porting some of it to Clara Iā€™d really want to know what would be useful for people. As it stands, you can view the history of a rule, history of a fact, ā€œevent logā€ (all inserts and retractions in order), see explanations for all of those (the rule conditions that were defined, the facts they matched on, the bindings of the variables, what was inserted or retracted), whether something was inserted or removed unconditionally, logically, or the result of schema enforcement, if it was schema enforcement which existing fact triggered the schema enforcement and the relevant schema rule, added and removed facts for a particular rule firing (i.e. diff), and the total set of facts that exist in the session at the end of any rule firing

šŸ‘ 2
alex-dixon 2018-05-17T14:36:46.000758Z

Itā€™s implemented as a client and serverā€¦the client for visualization, the server for receiving messages from the inspected session/app over socket

2018-05-17T14:46:15.000168Z

@alex-dixon sounds really useful. You should make it public in a github repo or something for people to try out šŸ™‚

alex-dixon 2018-05-17T14:58:33.000293Z

Yeah hahaā€¦I definitely will, Iā€™ve been dragging my feet because Iā€™m not completely happy with it

2018-05-17T15:34:29.000797Z

call it alpha šŸ˜›

dominicm 2018-05-17T16:07:00.000586Z

I have been using the fact graph for fact history, it's been a pretty cool demo. I wired it up to rhizome pretty easily, and was able to see that X created asg Y, and asg Y has property Z because of Rule A

šŸ‘ 1
zylox 2018-05-17T16:20:06.000600Z

im certainly interested as well. i agree with @mikerod, just mark it alpha. works for spec right šŸ˜›

dominicm 2018-05-17T16:22:32.000393Z

the alpha stuff works very well, as long as your namespaces are .alpha too

šŸ‘ 1
alex-dixon 2018-05-17T16:35:31.000778Z

Iā€™ll try to publish it this weekend, maybe just mentioning it here will make that easier šŸ™‚

alex-dixon 2018-05-17T16:35:42.000820Z

Thanks for the encouragement and feedback

šŸ‘ 1
1