-
Notifications
You must be signed in to change notification settings - Fork 34
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
updated files to support new tuple representation #1519
base: main
Are you sure you want to change the base?
Conversation
exitTuple(tup: QuintTup): QuintTup { | ||
// Process each element of the tuple | ||
const namespacedElements = tup.elements.map(element => { | ||
// If the element is a name, apply the namespace | ||
if (element.kind === 'name' && typeof element.name === 'string') { | ||
return { | ||
...element, | ||
name: namespacedName(this.namespace, element.name), // Apply the namespace | ||
} | ||
} | ||
// Otherwise, return the element as-is | ||
return element | ||
}) | ||
|
||
// Return a new tuple with namespaced elements | ||
return { | ||
...tup, | ||
elements: namespacedElements, | ||
} | ||
} | ||
|
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.
We actually don't need this! The IR transformer itself should already guarantee that we visited/transformed all of the elements before reaching the tuple. This works as it is right now because namespacedName
is idempotent (it can be applied more than once and the result will be the same as if it was applied once, that is, f(x) = f(f(x))
), but it will also work as if we remove this, and we should 😄
exitTuple(tup: QuintTup): QuintTup { | |
// Process each element of the tuple | |
const namespacedElements = tup.elements.map(element => { | |
// If the element is a name, apply the namespace | |
if (element.kind === 'name' && typeof element.name === 'string') { | |
return { | |
...element, | |
name: namespacedName(this.namespace, element.name), // Apply the namespace | |
} | |
} | |
// Otherwise, return the element as-is | |
return element | |
}) | |
// Return a new tuple with namespaced elements | |
return { | |
...tup, | |
elements: namespacedElements, | |
} | |
} |
@@ -166,6 +167,33 @@ export class ConstraintGeneratorVisitor implements IRVisitor { | |||
this.addToResults(e.id, right(toScheme({ kind: e.kind }))) | |||
} | |||
|
|||
exitTuple(e: QuintTup) { |
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.
As we did with the effects inferrer, I think we can also generalize something here so we don't have to repeat this code between exitTuple
and exitApp
. This will also repeat with the other structures (lists, maps, records, etc), so we can try to generalize when adding the next one.
Co-authored-by: Gabriela Moreira <[email protected]>
Co-authored-by: Gabriela Moreira <[email protected]>
Co-authored-by: Gabriela Moreira <[email protected]>
Co-authored-by: Gabriela Moreira <[email protected]>
Co-authored-by: Gabriela Moreira <[email protected]>
Co-authored-by: Gabriela Moreira <[email protected]>
Co-authored-by: Gabriela Moreira <[email protected]>
Co-authored-by: Gabriela Moreira <[email protected]>
Updated the tuple structure across the codebase from { kind: 'app', opcode: 'Tup', args: [...] } to { kind: 'tuple', elements: [...] }. This refactor improves clarity and consistency in tuple handling and removes support for the previous Tup syntax. All affected files and references have been modified accordingly.