datalog

quoll 2020-10-06T01:24:41.017200Z

Just to explain the basis of my question: it was based on the fact that “Datalog syntax” looks like Prolog. So for a Datomic query that asks, “How old is Alice?” I might have:

[:find ?a
       :where
       [?e :name "Alice"]
       [?e :age ?a]
To get the same thing with traditional Datalog, we would create a rule connecting names to ages and then query for the age:
nameage(N,A) :- name(E,N), age(E,A).
?- nameage("Alice", A).

quoll 2020-10-06T01:25:55.017400Z

Since the syntax of Datomic queries is just edn, then it doesn’t need lexing, and the parsing is not difficult. So I thought that perhaps you were looking to parse traditional Datalog.

quoll 2020-10-06T01:27:29.017700Z

Thanks for clarifying

lilactown 2020-10-06T02:12:20.018700Z

the problem with datalog is that you can embed arbitrary exprs into it - so it’s really bad for the “resolver” style of implementing

lilactown 2020-10-06T02:12:56.019600Z

you can’t always statically know what the full query is

lilactown 2020-10-06T02:13:14.020200Z

this is where pathom helps a lot, because it’s much stricter in its evaluation

quoll 2020-10-06T03:07:51.025200Z

I’m not really a fan of Datalog as a query language. Triple-pattern style where clauses with projection are much better. That said… I don’t understand what you’re saying here. I think I can guess what a “resolver” style of implementation is, but I don’t know what you mean by “statically know that the full query is”

lilactown 2020-10-06T03:13:55.029400Z

I’m basing my take on @mauricio.szabo ‘s message: > is there something that I can register "resolvers" and then query it with datalog? this seems to be borrowing from the way in which pathom and graphql services are built, where for each attribute you have some resolver which will handle looking up the information for that attribute. Thus, in order to construct a result a GraphQL or Pathom implementation simply needs to parse the query, look up and run the resolvers in the correct order

lilactown 2020-10-06T03:17:46.031300Z

it is more difficult to do this because you could get a datalog query like: [:find ?x :where [_ :attr attr] [_ attr ?x]]

grounded_sage 2020-10-06T13:09:24.031900Z

@mauricio.szabo I have asked for others to chime in which could answer your questions better.

grounded_sage 2020-10-06T13:10:48.032100Z

@quoll can you provide some resources to such a query language? I am very new to this field and have little context as to what you mean here.