Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Typeclasses & Modules

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Typeclasses & Modules


Chronological Thread 
  • From: Vadim Zaliva <vzaliva AT cmu.edu>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Typeclasses & Modules
  • Date: Mon, 18 Nov 2019 18:07:03 -0800
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=vzaliva AT cmu.edu; spf=Pass smtp.mailfrom=vadim.zaliva AT west.cmu.edu; spf=None smtp.helo=postmaster AT mail-io1-f46.google.com
  • Ironport-phdr: 9a23:yOJl8h/SkmkfMv9uRHKM819IXTAuvvDOBiVQ1KB41+gcTK2v8tzYMVDF4r011RmVBN6dsq4bwLGH+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhGiTanfL9/Ixe7oQrfu8QSnIBvNrs/xhzVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNXs15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRTiv6bpgRRn1gykFKjE56nnahcNwgqxVoxyvugJxzJLPbY6PKPZzZLnQcc8GSWdDWMtaSixPApm7b4sKF+cOMvxXoJT8p1sLsBCxBhOjBOfuyj9WnHD9wKo30/ogEA7c2AwgHswOv27PodrpMacSTPq5w7fVwjXedv5b3yr25obPchAku/6MXLRwfNLXyUY1EgPKkEycppDiPzyPyusNs3KX4PZnVeKqjWMstgJ/oiC3y8syloXEgpgZx1PE+Clj3Yo4JNy1RFR0bNOlFpZbqjuUOJFsQsw4RmFloCY6xaMCuZ68ZCUKzY4oxx/ba/CecoiI5Q/vWP+fITp3hX9pYr2/hxG18Uivzu3zSNO430pNripAitXMt3YN2ALP6sWfVPdx4kOs1SyM2g3T8O1IPEE5mKvBJ5Muw7M8jp8Tvl7CHi/ylkX2lqiWdkA89+i28evof7TmppqGO451kA7+NqUumtKlDukjPAkBQXOb+fim2LL/+E35Xa9GgeMrnanEqJzaP9gUpralAw9J1YYu8wqwDzC/0NgBgXYHKE9FdwmcgojyO1DOJej4Au2lj1Stljdr3fHGMaf7DpXDNHiQ2IvmKL168gtXzBc55dFZ/ZNdTL8bc9zpXUqkitXUDxpxAQWwwvjuQIFjxIoaWHyGKqScLeXfvULetbFnGPWFeIJA4GW1EPMi/fO71SZly29YRrGg2N4sUF79Bu5vcheSZGeqj9scQz9T71gOCdfygVjHagZ9InO7XqYy/DY+Ud70EorYWsamhaHH0SumTMQPOzJ2T2uUGHKtTL2qHvcBbCXIf51kmz0AELmmEsoviU/ouwj9xL5qaOHT/39AuA==

Example below demonstrates the problem I am having. I would like to define Module Type which is wrapper around a type and carries over an instance of a typeclass for this type.

Then I would like to use it when importing this module.
The direct approach does not work, as shown below. If there is
any way to make Et visible to typeclass resolution mechanism inside FooProperties? It is visible in general, not just to typeclass search:

(* Custom equality relation *)
Class Equiv (T: Type) := equiv: T -> T -> Prop.

(* A module to wrap a type which has `Equiv` instance *)
Module Type Foo.
  Parameter Inline t : Type.
  Context `{Et: Equiv t}.
  (* 'foo_ok' definition works here, as it finds "Et" as an instance of
  "Equiv t" *)
  Lemma foo_ok: forall (x y: t), equiv x y. Admitted.
End Foo.

Module FooProperties (F: Foo).
  Import F.

  (* The following prints:
     Et : Equiv t
   *)
  Check Et.

  (*
    The following fails with the error:

     Error: Unable to satisfy the following constraints:
     In environment: x, y : t
     ?Equiv : "Equiv t"
  *)
  Lemma foo_error: forall (x y: t), equiv x y.

Thanks!


Vadim Zaliva A button for name playback in email signature
CMU ECE Ph.D. candidate
Mobile/Signal/WhatsApp: +1(510)220-1060




Archive powered by MHonArc 2.6.18.

Top of Page