coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: ikdc <ikdc AT mit.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Opaque module typing with exposing function defs
- Date: Wed, 26 Apr 2017 17:10:39 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=ikdc AT mit.edu; spf=Pass smtp.mailfrom=ikdc AT mit.edu; spf=None smtp.helo=postmaster AT dmz-mailsec-scanner-7.mit.edu
- Ironport-phdr: 9a23:nb7OHRw9RwSZA2TXCy+O+j09IxM/srCxBDY+r6Qd1ewXIJqq85mqBkHD//Il1AaPBtSHraocw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze6/9pncbglSmDaxfa55IQmrownWqsQYm5ZpJLwryhvOrHtIeuBWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbOSxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDwULs6Wymt771zRRH1likHOT43/mLZhMN+g61Uog6uqRNkzo7IYoyYLuZycr/TcN4YQ2dKQ8ZfVzZGAoO5d4YPDukBMvtEoILgoFYOrBi+ChSwC+70zz9Ih2P20bck3Os8DAHLxQotFM8NvnTMtNj5KaQfXfq3waXSzDjObOla1Dn85YTQbxwsouuAUa9zfMfV00UiFwLIgk+OpYD5Pz6Y0PkGvXKB4Op6T+2vjnYqqwFvrTirwcchkpTGhocUy1zd8CV22oc1JdmjSEFlfdGoCYBQuD2AOItwRMMtXXtotD84x7EcvJ67fTQKxI45yBHCdvyLa4mI4hT9W+aNOTp0mXFodKi9ihqo8EWtyffwW8e13VpSqypKiNjMtnQD1xzJ7ciHT+Nw/kai2TmSyw/e8eREIUEolabBNZEu36MwmoIJsUvfBi/2hFn2jKiOe0o4/eio8v3rbanipp+BLIB5kRr+M6QrmsynG+s0KAkOX26B+eS9zrLv50P5QK8ZxsExx6LeqdXRIdkRjq+/GQ5clIg5uDilCDLz0dcUljFTLVFJczqCjpSvNl3TdqOrRcyjikihxW84j8vNOafsV83A
On 04/26/2017 04:57 PM, Julia Belyakova wrote:
Dear Coq users,
I guess it's a stupid question, but...
I want to define a module with certain parts being hidden. For this I
define a module type and then use opaque typing for the module. And the
problem is that now I cannot compute functions of the module, their
definitions are not accessible.
Please, find a simple example below.
Module Type Addition.
Parameter t : Type.
Parameter add : t -> t -> t.
End Addition.
Module MAddition : Addition with Definition t := nat.
Definition t := nat.
Definition add x y := x + y. (* I want this to be available *)
Definition priv_id (x : t) := x. (* This must be hidden *)
End MAddition.
(* priv_id is not available as desired *)
(* Compute (MAddition.priv_id 4). *)
(* add is available, but the call does not reduce to 7 *)
Compute (MAddition.add 3 4).
If I understand correctly, I don't think you can do this. The fact that the module type is opaque means that any program which uses a module with that type must behave the same way; in particular it may not unfold the definitions hidden by the module type. You could of course do this:
Module MAddition : Addition
with Definition t := nat
with Definition add := fun x y => x + y.
Definition t := nat.
Definition add x y := x + y.
Definition priv_id (x : t) := x.
End MAddition.
But if you want to be able to compute through [add], then perhaps the module type "Addition" isn't actually the interface you want to be using in the first place.
I don't know very much about the module system, so someone please correct me if this is wrong.
--
Istvan Chung
- [Coq-Club] Opaque module typing with exposing function defs, Julia Belyakova, 04/26/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, ikdc, 04/26/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Julia Belyakova, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Ralf Jung, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Julia Belyakova, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Jason Gross, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Jason Gross, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Jason Gross, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Jason Gross, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Jason Gross, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Julia Belyakova, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Gaetan Gilbert, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Julia Belyakova, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Pierre Courtieu, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Julia Belyakova, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Ralf Jung, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, Julia Belyakova, 04/27/2017
- Re: [Coq-Club] Opaque module typing with exposing function defs, ikdc, 04/26/2017
Archive powered by MHonArc 2.6.18.