datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
2018-11-01T18:31:56.004400Z

I have a somewhat unusual question: Given an AST for a programming language in a Datascript db, is it possible to identify dependencies with their db id, if all dependencies are db.type/ref? One problem I see is that they might not be immediate children of the node, but further down the tree. I know that datalog supports recursive queries, but my datalog-fu isn't strong enough for that (yet) 😉 The nodes are quite inhomogeneous (It's not a lisp tree sadly), so enumerating all possibilities by hand would be somewhat tedious, but theoretically possible

2018-11-01T18:47:23.005100Z

Cool, thanks, will check

2018-11-01T18:54:51.005300Z

Ah, actually the frontpage itself has a good example too:

(d/q '[ :find  ?u1 ?u2
        :in    $ %
        :where (follows ?u1 ?u2) ]
      [ [1 :follows 2]
        [2 :follows 3]
        [3 :follows 4] ]
     '[ [(follows ?e1 ?e2)
         [?e1 :follows ?e2]]
        [(follows ?e1 ?e2)
         [?e1 :follows ?t]
         (follows ?t ?e2)] ])
I was looking for something like that, coding it to a custom rule

2018-11-01T18:56:40.005500Z

I would expect that the pull based queries to have some issues dealing with cases where there can be more intermediate immediate steps with different child attributes

2018-11-01T20:49:01.005700Z

I found that I can generate this rule from the schema, that's pretty awesome 😈