-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve Eq
Hs
instances
#348
Conversation
The `Size` can be deduced from `Vec n NameHint`. This change moves the `induction` closer to where it is used.
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.
Reviewed over meet. Feel free to merge after making the changes discussed.
I think we shouldn't need Eq instances at all. This is all ugly and tedious code, and also error prone one. |
@phadej I think we got started on this path due to the |
@edsko, yes, https://hackage.haskell.org/package/tree-diff-0.3.4 does exactly that. I feel ashamed that I didn't notice that (and disappointed that nobody else either) for the seven years package existed. |
I received feedback about how `Vec.withDict` can be used to recover the `SNatI` dictionary of a `Vec`, and using it makes adding `SNatI` many constraints unnecessary. Thank you @sheaf! I also received feedback about using `GEq`. Thank you @phadej! This commit refactors the changes made to commit "Add Hs AST Eq instances, test using tree-diff" (`916ab6db`). It removed all added `SNatI` constraints and uses `GEq` instances. An unsightly aspect of the refactored code is the use of auxiliary functions just to bring type variables that are not part of the type signature in scope, but I do not know of a way to do this otherwise.
Based on feedback/guidance from @sheaf, `equals` from `HsBindgen.Util.TestEquality` and a new `ApEq` wrapper are used to significantly simplify the instance definitions. With a new `geqVec` function, auxiliary functions that just bring type variables into scope are no longer needed. Thank you @sheaf!
86fb276
to
5243b33
Compare
Implementing the Thank you for the update to |
This commit removes the Eq instances that were added in the following commits: * `916ab6dc` Add Hs AST Eq instances, test using tree-diff * `a02d5d28` Improve Eq Hs instances * `5243b337` Improve Eq Hs instances (2) Note that `ApEq` in `HsBindgen.Util.TestEquality` is *not* removed. Discussion: #348
I received feedback about how
Vec.withDict
can be used to recover theSNatI
dictionary of aVec
, and using it makes addingSNatI
many constraints unnecessary. Thank you @sheaf!I also received feedback about using
GEq
. Thank you @phadej!This commit refactors the changes made to commit "Add Hs AST Eq instances, test using tree-diff" (
916ab6db
). It removed all addedSNatI
constraints and usesGEq
instances.An unsightly aspect of the refactored code is the use of auxiliary functions just to bring type variables that are not part of the type signature in scope, but I do not know of a way to do this otherwise.