-
Notifications
You must be signed in to change notification settings - Fork 45
Respect the identity of variables, Part 1 #1830
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
Respect the identity of variables, Part 1 #1830
Conversation
12e78d1 to
d079c24
Compare
The goal of refactoring is to replace type Variable and the wrappers around it with type Variable1, and rename the latter. Note that this will make the SortedVariable class obsolete because all variables will carry a sort field at the top level; therefore, we will modify the SortedVariable class to carry the intermediate definitions we need for refactoring, and remove the class in the end.
d079c24 to
2ed1195
Compare
| :: ElementVariable variable1 | ||
| -> Identity (ElementVariable variable2) | ||
| trElemVar = sequenceA . (<*>) (elemVar adj') | ||
| trSetVar = sequenceA . (<*>) (setVar adj') |
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.
why did you write the signature for trElemVar but not for trSetVar?
| Just (SetVar setVar') -> setVar' | ||
| _ -> setVar | ||
| subst = TermLike.mkVar <$> rename | ||
| let rename = |
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.
I can't help notice that the complexity of the code has grown by a non-trivial margin. From 10 lines with easy-to-read-and-write code, we got to more than 30 of code with lenses
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.
Yes, it's unfortunate, but temporary: the lenses are a consequence of switching between representations of variables, and after I finish the next part of the changes, then all the lenses go away.
This pull request begins to fix #1545. Most of the changes in this pull request are simply consequences of the changes in
Kore.Syntax.Variable, so I recommend starting there.Summary
Variable1which carries a variable name and sort, representing an occurrence of a variable in a Kore pattern. UnlikeVariable, this type is parameterized in the variable name type.VariableNametype, representing the basic syntax of variable names.ElementVariableNameandSetVariableNamewrappers.SomeVariableName, which may be anElementVariableNameor aSetVariableName.AdjSomeVariableName, which represents mappings preserving the element- or set-ness of a variable. The name of the type owes to the adjunction betweenSomeVariableNameandAdjSomeVariableName. This is not as complicated as it sounds, but it bears close attention. Most of the changes in the pull request are related to introducing this type.NamedVariablefor variables, representing the isomorphism between_ VariableandVariable1 _.In the follow-up to this pull request,
Variable1 _will replace_ Variableand theNamedVariableclass will be obsolete. I wanted to get this in as a separate pull request because I think addingAdjSomeVariableNameis significant in its own right.Reviewer checklist
stack test --coveragestack haddock