Fork me on GitHub
#datascript
<
2018-11-01
>
mrchance18:11:56

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

mrchance18:11:23

Cool, thanks, will check

mrchance18:11:51

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

mrchance18:11:40

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

mrchance20:11:01

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