Fork me on GitHub
#datalevin
<
2022-05-02
>
vlad_poh02:05:26

How do i use 2 rules in a single query? This throws an arity error expected 3 got 4

(d/q '[:find ... 
       :in $ % ?p1
       :where [...]]
     db rule1 rule2 p1)
this throws a parsing error
(d/q '[:find ... 
       :in $ % ?p1
       :where [...]]
     db [rule1 rule2]  p1)
Can't find an example on the web for any clojure flavored datalog Am i thinking about this wrong?

zeitstein04:05:54

I would expect the second version to work. I'm not sure what the problem is without more details. Try looking through https://github.com/tonsky/datascript/blob/master/test/datascript/test/query_rules.cljc for usage examples.

dvingo18:05:51

maybe

(d/q '[:find ... 
       :in $ % ?p1
       :where [...]]
     db (into rule1 rule) 2 p1)

vlad_poh22:05:00

got the following

Cannot parse clause, expected (data-pattern | pred-expr | fn-expr | rule-expr | not-clause | not-join-clause | or-clause | or-join-clause) tennis 

Huahai22:05:48

These are inherited design from Datomic hence Datascript. We will develop a more fully featured rule engine before version 1.0. Stay tuned. Right now, my priority is to finish the query engine rewrite. The rule engine will also rely on a more performant query engine.

😀 1
vlad_poh23:05:59

@U0A74MRCJ thanks! looking forward to it. In this case my rule was wrong. Once i fixed it the query worked. Didn't realize i could do ors and ands. I wish there were a book on clojure's datalog dialect.