If I have some class Foo
and some record like
Record Bar := { carrier; carrier_foo :> Foo carrier }.
I'd expect that whenever bar : Bar
is in scope that instances for Foo bar.(carrier)
would be automatically resolved, but this doesn't happen. Have I misunderstood what :>
means?
For that I think you need to make Bar
a Class
instead of Record
Ah, that worked! Does :>
mean anything in a record? And will it screw things up to have a Class
with no parameters that I don't ever intend to be resolved by typeclass lookup?
In a record it makes a coercion.
Right, for example:
Record foo := { x :> nat }.
Check (fun (x : foo) => x : nat).
works only becuase of :>
I see!
in this case it may make more sense to do Record Bar := { carrier; carrier_foo : Foo carrier }. Existing Instance carrier_foo.
(without the :>
unless you also want it to be a coercion)
Is there a way to use an instance without the coercion?
S/use/get the effects of existing instance without getting the coercion/
Is :>> anyhow related?
(I’ve observed :> create coercions in Classes)
I don't understand the question, Existing Instance doesn't make it a coercion
:> means coercion for Record and instance for Class
see https://github.com/coq/coq/pull/13106 for :>>
IME, :> for class means “coercion and instance”.
But I’ll try again.
Okay, a basic experiment agrees with you. I remember this thought came from some concrete experiment, but it might have been a mistake indeed.
Last updated: Oct 03 2023 at 20:01 UTC