This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-13
Channels
- # adventofcode (4)
- # announcements (1)
- # babashka (7)
- # beginners (51)
- # calva (18)
- # cider (15)
- # clj-kondo (1)
- # cljsrn (6)
- # clojure (99)
- # clojure-dev (31)
- # clojure-europe (5)
- # clojure-france (2)
- # clojure-italy (3)
- # clojure-nl (14)
- # clojure-seattle (8)
- # clojure-spec (6)
- # clojure-uk (2)
- # clojurescript (23)
- # conjure (3)
- # css (6)
- # data-science (3)
- # datomic (19)
- # events (6)
- # fulcro (13)
- # graalvm (5)
- # honeysql (24)
- # inf-clojure (19)
- # music (10)
- # off-topic (28)
- # pathom (10)
- # rdf (15)
- # re-frame (11)
- # releases (4)
- # sci (1)
- # shadow-cljs (18)
@quoll Hey Paula, I wanted to ask some questions here that may also be relevant to others in the channel. I watched the presentation that Zach Oakes gave on O’Doyle Rules (https://www.youtube.com/watch?v=XONRaJJAhpA) and that made me much more interested in Rules Engines than I was before. I was wondering how Naga compares to it (and Clara Rules). One thing I’ve noticed is that the Datalog syntax in the README.md is Prolog-based rather than Datomic-style. Is the Datomic style also supported?
@U4P4NREBY Just a heads-up, Paula mentioned in #asami that she's on vacation (and offline) for a week or so. Might take her a few days to get back to you.
I’ll start by raising my standard objection that “Datalog syntax” really is Prolog syntax (with restrictions). Rich called it Datalog because it has Datalog semantics, but it’s his own syntax.
But I know what you mean, so to answer your question, yes. Internally, the rules get converted anyway. If you write your rules in code, then you HAVE to do it with the query syntax (unless you want to build up a whole lot of strings and parse them)
The easiest way to create rules is with a macro in naga.rules
called r
. This follows the Prolog convention of:
head :- body
So the Datalog rule of:
uncle(N,U) :- parent(N,P), brother(P,U).
Can be expressed as:
'(require naga.rules :refer [r])
(r [?n :uncle ?u] :- [?n :parent ?p] [?p :brother ?u])
About rule options... Naga was originally Datalog centric, which excluded negations in queries, retracting statements, or existential statements (such as mother(C,M) :- person(C).
)
Right now, Naga supports:
• existential statements (meaning that new objects can be created, like in the mother example there)
• query negations (via not
)
• limited retraction. This is when you update a value that already exists, and requires a retract/assert on the value, since everything is multicardinality. It’s done via a '
annotation on an attribute.