coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Talia Ringer <tringer AT cs.washington.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Looking up definitions from inside an ml plugin
- Date: Thu, 16 Nov 2017 10:17:54 -0800
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=tringer AT cs.washington.edu; spf=None smtp.mailfrom=tringer AT cs.washington.edu; spf=None smtp.helo=postmaster AT mail-vk0-f53.google.com
- Ironport-phdr: 9a23:+3vzmBRP8iA/ZTd9BohYMEmd/9psv+yvbD5Q0YIujvd0So/mwa67YhWN2/xhgRfzUJnB7Loc0qyN7PCmBDRIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnZBUin4YAFyP6H+HpPYp8WxzeG7vZPJMCtSgz/oXbp2LRz+lwTXucQMyd9+MKc3xRbTinBTPftf3mNpI12PmBC668utqs0wux9Msu4sopYTGZ7xeL41GORV
It is an i of type mutual_inductive, which is an alias for MutInd.t. You can find MutInd.t in names.mli.
You can get that from the AST in this way:
You can get that from the AST in this way:
| Construct (((i, _), _, _) ->
let mutind_body = lookup_mind i env in ...
| Ind ((i, _), _) ->
let mutind_body = lookup_mind i env in ...
To actually construct a name of an inductive type from a string is a little more complicated. I do it in this plugin in the function inductive_of_elim. It looks roughly like this:
let ind_label = Label.of_id (Id.of_string_soft ind_label_string) in
let ind_name = MutInd.make1 (KerName.make modpath dirpath ind_label) in
let body = lookup_mind ind_name env in ...
Where modpath and dirpath make the name fully-qualified.
I'm not sure why you have a string, but if you have a constant somewhere and just want to modify it a bit and then use that string to lookup_mind, your job is a little easier, because you can repr the fully qualified name:
let kn = Constant.canonical c in
let (modpath, dirpath, label) = KerName.repr kn in ...
Anyways, I suggest looking at names.mli, or whatever the equivalent is in the newest Coq plugin API.
- [Coq-Club] Looking up definitions from inside an ml plugin, Kenneth Roe, 11/16/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Talia Ringer, 11/16/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Talia Ringer, 11/16/2017
- Message not available
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Kenneth Roe, 11/17/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Talia Ringer, 11/17/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Kenneth Roe, 11/19/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Matthieu Sozeau, 11/19/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Kenneth Roe, 11/19/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Talia Ringer, 11/17/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Kenneth Roe, 11/17/2017
- Message not available
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Talia Ringer, 11/16/2017
- Re: [Coq-Club] Looking up definitions from inside an ml plugin, Talia Ringer, 11/16/2017
Archive powered by MHonArc 2.6.18.