I am trying to add attribute support for Typeclasses Opaque
and Transparent
and I have made a draft PR: https://github.com/coq/coq/pull/14685
However it doesn't work and I would like to learn why :-)
define "does not work"
I added a test case in the PR
Yes, but what's the error?
It doesn't recognize support for attributes
This command does not support this attribute: export.
[unsupported-attributes,parsing]
you're probably using the wrong attribute specification
let me look at what we do for other hint commands
But I thought this would be enough:
VERNAC COMMAND EXTEND Typeclasses_Rigid_Settings CLASSIFIED AS SIDEFF
| [ "Typeclasses" "Opaque" ne_reference_list(cl) ] -> {
set_transparency cl false }
| #[ locality = Attributes.option_locality; ] [ "Typeclasses" "Opaque" ne_reference_list(cl) ] -> {
set_transparency locality cl false }
END
sorry this is a poorly copied diff
it should indeed parse export
your example works for me ©
OK, then am I doing something stupid to test it
I run dune exec -- coqide
don't ask me, this is dark magic to me
I don't know of a way to make coqide really work out of the box
in theory you must call a shim
dune exec -- dev/shim/coqide-prelude
or so
Coqide and Coqtop (or rather Coqidetop) are two separate programs. If you just recompile Coqide, your changes are not taken into account.
Yes, hence the shim above.
But it has a net tendency to not work on a clean repo.
I usually have to build bits of world to make it work.
Excellent it worked!
@Ali Caglayan you should also call the same warning as for Hint Opaque without an explicit locality
I am starting to get slightly bored of the whack-a-mole game of flagging superglobal commands as we have random aliases all over the place.
Is it normal for Typeclasses Opaque
to be part of the ltac plugin even though it has very little to do with ltac?
I feel like it got left behind when some of the hint stuff was moved away from ltac
I invoke the historical-miranda-reason rights
Where does Hint Opaque give warnings?
Look for Hints.check_hint_locality
.
You can probably add the call to the classes.ml command
@Pierre-Marie Pédrot Are you testing the deprecation message for hints? If so how? Using test-suite/sucess?
I don't think we test anything.
You'll get errors if it interferes with output tests.
Doesn't look like we have any Typeclasses Opaque
or Transparent
in the test-suite however
If I want to add tests showing the desired behavior in the issue is now possible where do I put them?
It's not bugs right?
Perhaps test-suite/typeclasses?
looks ok indeed
Ali Caglayan said:
Perhaps test-suite/typeclasses?
no, those are fake tests, they never get run
this is not a joke ;_;
OK, then whats the better place?
success/
It's still time to deprecate these commands though...
You mean deprecate Typeclasses Opaque
?
I am a bit weary of this since users might not know what is going on under the hood
You can use typeclasses and have no clue about hints
These commands are explicitly documented as aliases.
If you use typeclasses without any clue about hint, you're probably a bit reckless...
We do it all the time in the HoTT library 0:-)
In fact, before looking into this issue today I was in the "no clue (about the implementation at least)" camp
Fair enough...
So I have run into a bit of a problem
The behavior of Typeclasses Opaque
in sections was essentially always #[globa]
.
So I changed the default behaviour of Typeclasses Opaque
to #[global]
but Hint
doesn't allow this in a section
I guess I will have to create overlays?
But this is kind of impossible, especially when Typeclasses Opaque
doesn't accept attributes yet
Or maybe I can get away with re-declaring Typeclasses Opaque
outside of each section?
Ali Caglayan said:
The behavior of
Typeclasses Opaque
in sections was essentially always#[globa]
.
are you sure? that sounds wrong
I don't know how else the errors here would happen however: https://github.com/coq/coq/pull/14685
Sorry I meant this one
https://github.com/coq/coq/runs/3116931816
Or maybe you are correct
Hmm I'll have to think about this more
The old code was calling make_section_locality
, which returns Local in sections and Global outside. You should not blindly pass the Default locality to Hints.add_hints
, as it would cause it to be interpreted as Global instead of Local.
Thanks!
So make_section_locality
returns a bool, is there a version that returns option_locality
?
OK I have just realised that we don't allow #[export] Hint Opaque
inside sections. @Pierre-Marie Pédrot Why?
no reason for this one, but some other Hint commands are hard to handle inside sections so they don't accept locality qualfiers
(this is due to the ability to add arbitrary terms as hints btw)
So people want exportable opaqueness in https://github.com/coq/coq/issues/14513 but this would basically require the underlying hint opaque command to do the same
From reading the Hint blah
code it looks very tied together so I don't really know how to go about doing this
The issue report is ambiguous. On the one hand, it asks for the same qualifiers as Hint Unfold (which doesn't accept them in a section) but the intended use case is precisely outside of this fragment.
For the time being I'd simply defer the decision to the underlying command and handle Typeclass Opaque really as a trivial alias.
I would love to have #[export] Hint Opaque
. All our definitions live in sections and almost all of them need to be Hint Opaque
for performance reasons. Right now we usually have to have two Hint Opaque
blocks, one in the section, and one with #[export]
after the section. It is very easy to only add a new definition to one of these two blocks (usually the one in the section) and thus lose out on performance. Sometimes people forget entirely about the block with #[export]
or just copy the previous block without adding #[export]
. It's quite a mess.
it's not very hard to implement
barring idiosyncrasies of the hint code, that is
if you get my last round of cleanup PRs to get merged quickly I'll have a look at it
@Pierre-Marie Pédrot Whats a good example of an alias to have a look at.
I want to essentially write Hint Opaque in the grammar for Typeclasses Opaque but I have no idea what to call
hmm, I don't think there is a trivial way to do that
AFAICT there is no way in VERNAC EXTEND to parse arbitrary attributes and pass them to the underlying command
also where do the locality attributes get passed to the hint commands?
magic!
in vernacentries because these are hardwired commands
I'm looking at comHints.ml and I don't see anything about locality
ah
look at Vernacentries.vernac_hints
Maybe time for a vernac notation? ;-)
Pierre-Marie Pédrot said:
if you get my last round of cleanup PRs to get merged quickly I'll have a look at it
I was looking at coq/coq#14675 but it was sneakily merged before I could make sense of the changes. What other cleanup PRs need feedback?
yes, it's getting merged fast indeed
there is https://github.com/coq/coq/pull/14615 which you already commented on
Just FTR on what people want, even if we can't have it, we probably want all qualifiers on all commands. Just today we had to workaround the lack of global
on canonical instances, because not like all modules are meant for imports.
“you think it takes a PhD to write Haskell? What about a language where a PhD is not enough?” :-P
(me ranting on that discussion). Anyway, </rant>.
Last updated: Sep 09 2024 at 06:02 UTC