clara

http://www.clara-rules.org/
2018-08-09T16:47:56.000231Z

@jeremy642 @mikerod this might be useful in combination with Mike’s suggestion of using Java objects as facts that you could translate into Clojure objects if desired: http://www.clara-rules.org/docs/java/ Basically Clara has a wrapper that you can use instead of needing to do the interop glue work yourself. In case you weren’t already aware.

2018-08-09T16:49:44.000463Z

Also FYI Clara will use the bean properties on Java objects to allow field use by name in the DSL, that isn’t just for records

2018-08-09T16:50:39.000040Z

i.e. Object A has a “getB” method, you can just refer to “b” in a condition like [A (= b some-value)]

jeremy 2018-08-09T16:51:09.000412Z

My rules implementation does not use Java types for fact types. So the question was how to handle the interop.

jeremy 2018-08-09T16:51:24.000340Z

(defrule new-return
  "The service is a new return."
  [:approval-status (= (:value this) :new-return)]
  =>
  (insert! {:type :rule/result
            :id :new-return
            :priority 2}))

jeremy 2018-08-09T16:52:27.000326Z

(r/insert {:type :approval-status :value :new-return})
is how I would insert using clojure.

jeremy 2018-08-09T16:53:43.000524Z

Without changing the rules to beans or defining the facts with defrecords. The big ?? was how to allow Java to create maps with the keyword format that matched the rules properly.

2018-08-09T16:54:53.000201Z

Perhaps write a rule that matches on Java maps and translates them, then inserts the result? That way you could just insert the Java map into the session

2018-08-09T16:55:32.000177Z

That rule could then just not do anything if only Clojure maps were in the session

jeremy 2018-08-09T16:56:06.000087Z

So that's one thought. I could write new rules that's sole job was to convert say a Java map if matches to a clojure map.

jeremy 2018-08-09T16:57:29.000364Z

I haven't progressed on any implementation yet. Been busy but I have some ideas to play with.

jeremy 2018-08-09T16:57:31.000214Z

:thumbsup:

2018-08-09T17:02:26.000201Z

Note that Clojure maps also implement Java’s map, so you’d need to guard against an infinite loop there (i.e. require that it a Java Map but not a Clojure map)

jeremy 2018-08-09T17:14:26.000465Z

Thanks

jeremy 2018-08-09T17:15:14.000471Z

I noticed that clara-rules is on the tech radar by thoughtworks. https://www.thoughtworks.com/radar/languages-and-frameworks

👏 1
🎉 2
2018-08-09T22:57:24.000159Z

Saw this one back when it was new on there. Pretty cool though!