clara

http://www.clara-rules.org/
2020-12-23T12:26:23.180900Z

Hi, i have a question about the dynamic creation of sessions: as I understand from the docs, mk-session doesn’t work for cljs, because the rule compilation is done at macro compile time. But it’s not clear to me if the macro compiling is only referring to the defrules and namespaces, or also “deeper”. Specifically, is it possible to dynamically create a session in clojurescript if the rules are provided already in the output form of the defrule macro, so with the explicit :lhs and :rhs in a map?

2020-12-23T12:28:20.183100Z

My usecase is the following: I promised my customer to allow for dynamic addition of (simple) rules through a web interface. Those rules would be used together with pre-defined rules in another web app. Of course I can run the rule execution on the backend and communicate between front-and-backend, but running it on the frontend would be more elegant…

2020-12-23T12:30:50.184600Z

If it’s not possible, a follow-up: would it work to do the dynamic (re)compilation on the backend, and then serialize the session in fressian, send it to the frontend and unpack and use it there?

2020-12-23T20:22:19.186100Z

@mathias_dw the session must be compiled in clj space. It is compiled to data structure but also has Forms that need to be compiled by the cljs compiler - such as functions

2020-12-23T20:22:43.186700Z

So the cljs compiler must Pre compile all of the session structure resulting in JS

2020-12-23T20:22:56.187300Z

That JS would evaluate on client. You can’t dynamically alter it all in JS

2020-12-23T20:23:19.188Z

It’d require having the whole cljs compiler available in the JS. Which is possible. But not the usual setup for a web app

2020-12-23T20:23:39.188700Z

And even the. Would require Clara to support self hosting. Which I don’t think it may fully do yet

2020-12-23T20:24:16.189700Z

I have been working (slowly) on a big overhaul of the mechanics of how cljs is compiled in Clara. But it doesn’t change above.

2020-12-23T20:24:41.190200Z

Serialization as freesian won’t work though

2020-12-23T20:24:49.190500Z

It’s not a “pure data structure”

2020-12-23T20:25:45.192Z

ie. Has things like functions. And possibly closures etc. Could try serializing fn’s but that’s a whole other problem space and has it's limits

clyfe 2020-12-23T20:31:38.192400Z

@mathias_dw maybe the competition helps https://github.com/oakes/odoyle-rules

2020-12-23T21:20:56.197100Z

Thanks a lot, guys! I'll just run it on the backend then. I did see odoyle rules, but I definitely want truth maintenance.

👍 1
2020-12-23T22:34:56.197800Z

Seems perhaps odoyle is too different to be true “competition”

2020-12-23T22:35:52.198500Z

Or should there be one rules engine to rule them all? 😛