-
Notifications
You must be signed in to change notification settings - Fork 463
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
CoeFun
and implicit arguments
#6124
Comments
|
@Kha I think there's a misunderstanding.
That's exactly what it fails to do, hence this issue. Instead of coercing to "the latter" -- whatever is written in the instance head, it coerces to what is actually the type of the instance body. |
Oh! I will reopen then. It would still be good to know more about the practical relevance of this issue, is there a specific use case? |
I bumped into this by accident more than anything. I had structure NatTrans (f g : Type u → Type u) [Functor f] [Functor g] where
app : ∀α, f α → g α
preserves_map : ∀α β h xs, app β (h <$> xs) = h <$> app α xs and I decided to define a instance [Functor f] [Functor g]
: CoeFun (NatTrans f g) fun _ => ∀{α}, f α → g α where
coe := NatTrans.app which reproduces this bug. The easy work-around of course is to instead define it as instance [Functor f] [Functor g]
: CoeFun (NatTrans f g) fun _ => ∀{α}, f α → g α where
coe η := NatTrans.app η _ but I was nevertheless surprised that the implementation of an instance can affect how its use-sites are typechecked. |
I don't see any good way to have it use the type in the Maybe a solution here is a linter that warns if the types don't have the same implicitness and optParam/autoParam annotations? (Another practical consequence is when we have a |
Prerequisites
Please put an X between the brackets as you perform the following steps:
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
Function applications going through
CoeFun
do not respect the implicitness of the parameters declared in the instance head, rather they take the implicitness information from the instance implementation.Context
Steps to Reproduce
Expected behavior:
Foo.app foo (α:=Type) (x:=Nat)
, and infer the typeType
Actual behavior:
Foo.app foo (α:=Nat)
and infers the typeNat → Nat
.Versions
4.13.0
Additional Information
The problem can be reversed by making the structure field have implicit
∀{α}
and the instance head have the explicit∀α
.#1891 seems relevant.
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: