-
Notifications
You must be signed in to change notification settings - Fork 339
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
Reassigning fixity/syntax during renaming import #1346
Comments
See also issue #978. Original comment by |
We can almost handle this situation without changing Agda: open Product using (_×_)
infixr 5 _∷_
pattern _∷_ x xs = Product._,_ x xs
open List
-- Non-empty lists.
List⁺ : Set → Set
List⁺ A = A × List A
test : List⁺ Bool
test = true ∷ false ∷ [] However, the last line is rejected:
This looks like a bug to me. I think that pattern synonyms should be open List
open Product using (_×_)
infixr 5 _∷_
pattern _∷_ x xs = Product._,_ x xs
Is there a reason for not allowing the two pieces of code above? Original comment by
|
I've changed my mind. I don't want to explain what should happen if an overloaded pattern synonym expands to multiple expressions, each with multiple overloaded constructors. I'm against fuzzy fixities, but perhaps it would be useful to be able to assign a new fixity when importing an operator. Original comment by
|
Also: define some more Null instances
The new fixity overwrites the nameFixity in the A.Name.
Also: define some more Null instances
The new fixity overwrites the nameFixity in the A.Name.
The fix of #4316 has uncovered a bug related to the fix of this issue. To reproduce (using a recent version of Agda without the fix of #4316):
The file
|
I added a |
We run the test suite with all the GHC versions supported in the |
I have disabled the test case, and we should fix this issue before the release. |
I looked at my code and it is correct as far as I can see. However, there is an underlying design issue with the handling of concrete/abstract names. My theory why this issue surfaced with your refactoring of Import is the following:
My general concerns with the design of concrete/abstract names are:
I guess at some point there was no need to distinguish between concrete name ID and abstract name ID, and this may have caused fixities to be attached to abstract names. But this breaks if one allows fixity of an operator to be changed in the same way as the concrete name may change. One temporary fix for the issue would be to make the serializer sound, so that it no longer conflates different abstract names with the same NameId. A more principled fix would separate fixities from abstract names and rethink how to organize the relation between concrete and abstract names. Note that this relation is n:m, meaning one concrete name can stand for different abstract names in a scope (AmbiguousQName), and one abstract name can have different concrete renderings (something we already struggle with heavily in the printer). |
There might be already a hook in the serializer to have a more refined test for abstract name equality: agda/src/full/Agda/TypeChecking/Serialise/Base.hs Lines 73 to 78 in ea6675f
UPDATE: adding fixity to this name identification did not yet do the job. |
Adds Fixity to ANameId to separate A.Name s with same NameId but different Fixity in memotable for A.Name. Does not seem to do the job yet: test/Succeed/Issue1346Import.agda still fails, old fixity is used.
How is this a regression? The reassignment feature has not been released. |
Having fixities in the abstract names also breaks printing after changing the fixities: postulate
A B C : Set
module M where
infixl 4 _+_
infixl 6 _*_
postulate
_+_ _*_ : Set → Set → Set
T : Set
T = A + B * C
open M renaming (_*_ to infix 2 _*_)
test : T → A + B * C
test x = x This prints:
|
QNames are shared based on name id, which loses the fixity information (if changed). We care about this in the scope, so serialize fixity separately for Scope.Base.AbstractName
…tually choose different concrete names for the same abstract name can have different fixities!
Out of scope names are now printed with `noFixity`
#1346: Handle updated fixities when serialising and printing
One of the test cases ( |
That test case is related to #4472. |
Singled out from issue #1194.
This no longer works, but maybe should, as the user has no means to change a fixity during import:
We could implement fuzzy fixities (:: has fixity 4-5), or extend the
"renaming" syntax to include fixities or syntax.
Original issue reported on code.google.com by
andreas....@gmail.com
on 6 Nov 2014 at 6:50The text was updated successfully, but these errors were encountered: