Skip to content
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

Prevent HSubst ? ? instance from being resolved arbitrarily with Hint Mode. #11

Open
Blaisorblade opened this issue Jan 6, 2019 · 0 comments

Comments

@Blaisorblade
Copy link
Contributor

Instance search for HSubst vl ?X picks an arbitrary solution instead of giving an ambiguity error, and that is only desirable for languages with one HSubst instance. So it's easy to accidentally declare lemmas for the wrong types and notice later.

This is a matter of design choice, but using Hint Mode seems fairly common practice among typeclass users.

Below's an excerpt from some development of mine:

Instance Subst_vl : Subst vl := vl_subst.
Instance HSubst_tm : HSubst vl tm := tm_hsubst.
Instance HSubst_ty : HSubst vl ty := ty_hsubst.

Goal ∀ s x, x.|[s] = x.
(* x is inferred to have type [ty] because that was the last declared instance — swapping the instances changes the type. *)
Abort.

Hint Mode HSubst - +: typeclass_instances.
(* [Hint Mode HSubst - !: typeclass_instances.] would also work in this test, but I can't think of a case where that's preferable. *)
Fail Goal ∀ s x , x.|[s] = x.
Goal ∀ s (x: ty) , x.|[s] = x. Abort.

I'm aware the library is not actively developed, but it is actively used, so this might be useful to other readers.

Blaisorblade added a commit to Blaisorblade/dot-iris that referenced this issue Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant