-
Notifications
You must be signed in to change notification settings - Fork 122
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
Lift the "field must have the same type in all constructors" restriction [was: Field name conflict bug in Enum]. #994
Comments
Ddlog requires that fields with different types in different constructors have different names. |
For the other question, typedef Item = ItemNode{node: Node} | ItemEdge{edge: Edge} Apologies about brevity and poor formatting. Typing on the phone. |
By the way, this restriction was borrowed from Haskell and may not actually be necessary in ddlog. We may get rid of it in the future. |
Thanks for answering me on your phone! I still don't have time (mainly because of procrastination) to look at |
I was hoping we'd convinced you to use ddlog instead of its internals :). There's unfortunately way too much on my to-do list to help with that feature in the near future. As for the field name restriction, it's not just a matter of removing the check. We should also make sure it doesn't break type inference or any other part of the compiler, add tests for it, etc. |
@ryzhyk You are very close to convincing me to use ddlog directly. I tried my own implementation built upon internals but does not work well. I'm still exploring the potential of ddlog to suit my needs in FORMULA and figure out if they have the exact same semantics despite using the same or similar syntax. One of the great things FORMULA has is nested aggregation (aggregation when certain constraints are satisfied but those constraints also have aggregation inside them) even though it's not used very often. The aggregation in ddlog seems to be highly customizable and I'll do more experiments on it.
Maybe at the end I can just add a feature to ddlog if the feature I need does not exist or a wrapper on top of ddlog. We will see. Do you guys have a slack channel for ddlog users? |
There's a gitter link in the readme. Or feel free to use the discussions section on GitHub. |
I'm trying to define a new type that could be either string or integer. My first try is to write
typedef NID = string | u32
but apparently not supported by ddlog so I came up with this onetypedef NID = StrId {nid: string} | NumId {nid: u32}
. The error message I got iserror: graph.dl:10.15-11.1: Field nid is declared with different types
saying theStrId
andNumId
cannot have the same field but it does not make sense since they are different constructors.It could be a bug in the compiler and I also wonder what's the best way to write a union type that represents the union of multiple primitive types?
The other similar question is how to reuse the types defined in the relations if I want a union type like
typedef Item = Node | Edge
whereinput relation Node(id: u32) input relation Edge(src: Node, dst: Node)
The text was updated successfully, but these errors were encountered: