-
Notifications
You must be signed in to change notification settings - Fork 688
Interpreting a casted term in the scope bound to its type if any #6134
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
Interpreting a casted term in the scope bound to its type if any #6134
Conversation
I haven't checked how the other binds are called in the code base currently but I would be in favor of uniformity of naming. For instance, in Elm all the binds are called As for the order of the arguments, the “standard” order coming from Haskell is to put the argument encapsulated in a monad first, and the function then, but Elm has recently decided to change this order for a very good reason: compatibility with the Just 1
|> Maybe.andThen (\x -> if x = 0 then Nothing else x + x)
|> Maybe.map (\x -> x - 1) But while I like this order of argument better, I think the most important thing is consistency. So if Coq has already got binds with the other order, keep the other order for this new bind as well (unless we change the order for all the binds at once). |
There is already not a lot of uniformity. For instance the Anyway, there are many ways to look at an object. Shall we favor a name which reflect some intuition of the object, or another intuition? Shall we reflect algebraic properties of an object, but why such property and not another one. But I think it is also important to share a common language, and that's why I preventively raised the question. |
A rebase seems needed. |
19394bc
to
21d1bdf
Compare
This PR introduces incompatibilities in HoTT and math-classes:
|
0c17fbf
to
ab78604
Compare
It's a small change. I can live with that for math-classes. |
Just making sure: is this fix backward compatible? |
What breaks if |
Looking at the commits to HoTT: oh this is interesting. I think the thing I actually want here is to be able to bind I'm also curious about the alternative of not removing the current local scope if no scope is bound to the type. What breaks if we do this instead? |
ab78604
to
11427e3
Compare
I'm sorry @JasonGross, but I don't know how to help here. I don't know HoTT well enough to understand the ins and outs of a choice or another. Maybe could you just tell me if you're ok with the patch or if you'd prefer another one.
You mean as a general rule (rather than for the particular case of HoTT)? Probably nothing would break further since this is the strategy applied up to now. I don't have a strong opinion. It looks a bit ad hoc to me but maybe it would be convenient in practice. I don't know if e.g. @ggonthier, who proposed the change, has an experience to share |
@herbelin I'm willing to accept the patch. I'd still be interested in the feature I mentioned; shall I open a new issue to request the ability to do things like |
Well, yes. (And this reminds me of similar requests for coercions.) And, on my side, I wonder whether there would be some need or support for an explicit syntax for temporary scope or to-stack scope in situations where the other semantics is taken. The current syntax either adds the scope to the stack ( In particular, this is obviously related to #3990, though I feel that the examples in #3990 are asking for more typing invariant being propagated, something that can be achieved more easily with typeclass-based notations. Being short in available time, I'm stopping there. BTW, it would be useful to have a comparison of the advantages and drawbacks of scope-based vs typeclass-based notations (or maybe such comparison already exists?). |
#6133 is closed and now part of this PR. For #982, I'll have to check but I suspect that it should be autonomous.
There are still a few incompatibilities (in HoTT and formal-topology), so I wonder whether @JasonGross' proposition of a mixed strategy (i.e. propagating the surrounding temporary scope if the type is not bound to a scope) could be a good compromise. Somehow, more user feedback would be useful. Maybe should we explicitly notify some people, e.g. those who participated to #3990, to take part to the discussion (and at the same time I know that everyone is very busy...). In any case, my current view is to take a couple of days for letting mature what could be the optimal policy. |
It has been a bit more than a couple days, any conclusions? |
OK on my side. |
I'll merge by the end of next week if there are no more comments. |
c0620be
to
55e251b
Compare
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.
Wording suggestions
Since those are output tests, the type will be tested in the output anyway.
…n time. Note that the feature implemented natively is different from the one implemented by the two deleted cast notations to a sort as the latters are "only parsing" while the native implementation is also for printing.
This extends interpreting in type_scope a term casted by a sort. See discussion at issue rocq-prover#6077.
See discussion at issue rocq-prover#6077. Works only when part of a recursive notation with binders yet, and not for printing.
55e251b
to
fd3880f
Compare
de384ef
to
f99eb0d
Compare
…-scope-bound-to-type Adapt to rocq-prover/rocq#6134
f99eb0d
to
3ed7590
Compare
Let's finally merge this almost six years old PR. @coqbot merge now |
This is a proposal in relation to the discussion at #6078.
It proceeds in several steps depending on taste:
type_scope
when casted by a sortssreflect.v
There are more to do about the last step but that will become easier in the context of the more regular parsing of patterns in #982.
Note 1: I have a terminology question: how to call the
bind
inOption
? In which order should be its arguments? (I tentatively called itcompose
.)Note 2 : This PR depends on #6133 (replaced by #18031) and
#982 (merged)shall depend on it for interpreting casts inpatterns.
Fixes: #14959
Overlays (to be merged before the current PR)