-
Notifications
You must be signed in to change notification settings - Fork 54
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
Datatypes RFC- Clarifying union
vs set
#309
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that the current behavior would be clear if we didn't allow functions that return eqsorts (any sorts defined in the program) to have merge
or default
. union
could be used on any two eqsorts, whereas set
could also be used on functions that return primitives (all non eqsorts). default
on a function that returns eqsorts could be rewritten with an initial union
, so the real sticking point is how we allow defining merge
attributes on functions that return eqsorts.
Is that your understanding as well?
If so, I might find it helpful to start by looking at the use cases so far with merge
used, which is mainly in the eggcc
example, to see how this drives the desired behavioral design space?
I suggest this because I personally am still unclear from any sort of first principles of the semantics what would be intuitively correct or obvious.
I do think I have a handle now on the current behavior of how this interacts, like by looking at this example:
(sort Math)
(function i (i64) Math)
(function add (Math Math ) Math)
(function f () Math :merge (add old new))
(set (f) (i 10))
;;(union (f (i 3)) (i 1))
(union (f) (i 11))
(set (f) (i 12))
(union (i 12) (f))
(set (f) (i 13))
;(union (f (i 3)) (i 10))
Edit: read more closely Yes, the main difficult part is the combination of merge function and eqsort as the output. |
I think of functions like |
Yeah, I mean, I think that's where it's odd, it acts like a value when calling
Hence why I was curious to learn more about how you are using the behavior in the |
Exactly- that's the confusing part. I'm proposing that we stop treating it the same as datatype for In |
For example, in that visualization I would show |
I wonder if this creates issues. It is a common practice to have a function like |
On the other hand, the confusion in the eggcc extraction can be solved by having a different kind of datatypes that never union (like normal ADTs in a functional language): |
Yeah I was thinking about this as well, if there is a way to define specific constructors as unable to be unioned with each other. Like in the |
I think adding terms and functional programming would certainly help, but would also be a big change. Also, it's unclear how the functional programming would compose with egglog rules- what if I want to put an eq-able term inside a term? Or vice-versa? |
No description provided.