-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Structs, Enums and Non-Copy values as Ground Terms. #1
Comments
Hey @eqv! Thanks for the suggestions. I think it should be possible to allow For destructuring, that's a great idea! There's a minor syntactical problem because I can't distinguish binding a Datalog variable with destructuring, versus making a function call or actually constructing a constraint using Datalog variables. For example, Instead, what about adding a third type of syntax ( Output(i) <-
Input(foo),
if let Opt::Foo(i) = foo;
// or
Output(i) <-
Input(foo),
if let Opt::Foo(i) = foo,
Input(Opt::Bar(i)) Would love to hear your thoughts on this design choice. I think this might solve both the destructuring problem, as well as the problem of just allowing temporary bindings in rules :) |
That's pretty amazing. I actually tried both options just to see if they work! So I think they are pretty intuitive. In the case |
Just as an update, I haven't been able to get the code working for non- crepe! {
@input
struct Edge(String, String);
@output
struct Reachable(String, String);
// Transitive closure
Reachable(n.clone(), m.clone()) <- Edge(n, m);
Reachable(n.clone(), m.clone()) <- Edge(n, k), Reachable(k, m);
} Perhaps you can try to serialize your data into Something that might help would be to allow lifetime parameters in relations. I'll make a new issue for this. Working on the pattern matching next! |
Would the solution above still work for copy types without explicitly calling clone? In that case it would seem like a pretty good option? The thing is, I was pretty much trying to avoid copying complex data structures by adding a Rc, which is not copy ^^. |
Why would an |
Yeah that would work as well, and be more efficient, but it's easier just to slap an Rc on it, clone everything all the time and call it a day, so I tried that first. |
You should be able to destructure with |
Sweet! Thanks a lot! |
It seems that the ground terms are limited to types implementing Copy, could this be loosened to contain values that are only Clone?.
In a similar vein, it seems that no pattern matching can be used in the body of a clause. For program analysis, it would be super useful to do stuff like this:
The text was updated successfully, but these errors were encountered: