Ok here's the datalog-to-datafrog "prototyping compiler" PR I mentioned before: https://github.com/rust-lang/polonius/pull/132 it does help when trying out rules (or doing Demand Transformation)
I've been bitten by weirdness around
rustfmt and whitespace line-endings inside the macro, so I'm not sure it'll pass CI. (It does pass locally, but was having random whitespace added/removed). It's not supposed to be especially robust or anything, just giving it valid decls and rules, and it should work. (It's also inefficient & cloning strings left and right but oh well :)
let me know what you think
I think it’s pretty gosh damned cool is what I think
(it's still very buggy but I'll fix it over time, add tests etc)
(yeah, maybe that should be in its own repo temporarily, until it's more stable and better tested, before being upstreamed in datafrog, so I'll close the PR for now and move it to a more appropriate location)
There might even be a case for it being its own crate perhaps?
That way, it could be used for code-generation as a dev-dependency like for example lalrpop
maybe. Although it's not a complete solution that will take all datalog programs and spit out a perfect datafrog computation (datafrog has its own limitations and API requirements), I'm mostly interested in making it easy for us to test out things in polonius. I'll put it in its own "utils" crate for the time being, maybe with some of the other hacky things from my datafrog fork (eg "datalog provenance" AKA a println for every rule firing, and a function that extracts some target tuple's provenance from this log)
datafrog generator moved here https://github.com/lqd/datapond @Vytautas Astrauskas
(I hope it helps but it's likely not going to work 100%, it's really only intended in the limited context of polonius, not every datalog computation; and even then only gets you part of the way there, you still need to know datafrog and how to set it up etc)
of course as soon as I add why-provenance, I actually also need why-not-provenance to understand what is going on in the flow sensitive equality variant :sweat:
datafrog generator moved here https://github.com/lqd/datapond Vytautas Astrauskas (I plan to dogfood it there for a while, maybe add DT to it, etc, and then see what Niko and Frank think about upstreaming those to datafrog directly)
@lqd Are you currently working on datapond?
I would like to start using it for my project and, therefore, would like to finish converting it into a procedural macro.
@Vytautas Astrauskas I have been looking at different examples to find more bugs, and fixed a few, but there are more (related to renaming/arguments and index uses, etc) — but if "currently" means "right this second" then no :) I have seen you push cool new work! I also seem to have lost the query syntax we looked at during rustfest so haven't been able to do a lot wrt syntax/parsing unfortunately (but as mentioned I wanted to try more rule examples to find bugs first)
(I think we’d want to test your queries before finishing the proc macro though ? Just to make sure it handles enough of what you need correctly-ish)
@lqd Have you pushed all your changes? I am thinking to look into it in 4 hours or so.
yeah, the rest of my (local) WIP isn't big and can be rebased easily
Could you still please push it to some branch?
I would like to restructure code a bit to make it easier to maintain, which would make your changes impossible to rebase.
@Vytautas Astrauskas I don't have access to this computer for a few days :/ go ahead don't worry about it, I'll take care of that afterwards, it was mostly about filtering index uses (so that random variable renaming would not generate duplicate useless indices)
I also wanted to make structural changes so that it's also easier to test in isolation but haven't started yet
Let's see how far I get :smile:.
good luck :D
(and also thanks <3)