coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jean-Marie Madiot <madiot AT gmail.com>
- To: Coq Club <coq-club AT inria.fr>
- Subject: [Coq-Club] Partial modification of records
- Date: Wed, 28 Jul 2010 16:44:31 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=SlC1WsUycLCDNuCF/Jrq51ACgFotOEe5vDWagrBDA0VxIZ+nj5e1FbpbwqoUzwqTzX xLKKbKG2DIcXkMbrY1EW+4JoZ/Vf8SD+mccoTdOfN8lYO0DhP8QLfKxDe772c87XKi4T iUuCdyAy8srrPYg+3kCvMnIZTjzrPzHRUil9w=
Hello all,
I'm currently using the Record syntactic sugar and I was wondering if
it is possible to build a record instance from an existing one while
modifying only a few fields. To be clear, I have a record with many
fields, like this:
Record rec := rec_cons {
rec1 : nat;
rec2 : nat;
rec3 : nat;
recdots : nat
}.
(* and I built an instance of rec: *)
Definition r : rec := rec_cons 1 2 3 4.
Definition r2 : rec := {| rec1 := 1; rec2 := 2; rec3 := 3; recdots
:= 4 |}. (* same thing *)
(* now I want to make an instance based on r but modifying only one
field, like that: *)
Definition r' : rec := {| r with rec2 := 20 |}.
But it does not work like that. (This is inspired from the ocaml
syntax). Is there another way? I know I can do such a thing by
defining my own function depending on my record type and which field I
want to alter -- and even setting up a notation for it -- but since
records are already just syntactic sugar, maybe it is possible to have
something more general?
Or maybe it interferes with the existing notation system?
Regards,
Jean-Marie
- [Coq-Club] Partial modification of records, Jean-Marie Madiot
- Re: [Coq-Club] Partial modification of records, Gregory Malecha
Archive powered by MhonArc 2.6.16.