Skip to content

Commit 285a927

Browse files
committed
api: coq.mod[ty]path->library
1 parent e7c8972 commit 285a927

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## UNRELEASED
4+
5+
### API
6+
- New `coq.modpath->library`
7+
- New `coq.modtypath->library`
8+
39
## [1.16.0] - 10/11/2022
410

511
Requires Elpi 1.16.5 and Coq 8.16.

coq-builtin.elpi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,14 @@ external pred coq.modpath->path i:modpath, o:list string.
15941594
% component is a separate list item
15951595
external pred coq.modtypath->path i:modtypath, o:list string.
15961596

1597+
% [coq.modpath->library MP LibraryPath] extract the enclosing module which
1598+
% can be Required
1599+
external pred coq.modpath->library i:modpath, o:modpath.
1600+
1601+
% [coq.modtypath->library MTP LibraryPath] extract the enclosing module
1602+
% which can be Required
1603+
external pred coq.modtypath->library i:modtypath, o:modpath.
1604+
15971605
% [coq.term->string T S] prints a term T to a string S using Coq's pretty
15981606
% printer
15991607
% Supported attributes:

src/coq_elpi_builtins.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,6 +3586,20 @@ coq.id->name S N :- coq.string->name S N.
35863586
(fun mtyp _ ~depth h c state -> !: (mp2path mtyp))),
35873587
DocAbove);
35883588

3589+
MLCode(Pred("coq.modpath->library",
3590+
In(modpath, "MP",
3591+
Out(modpath, "LibraryPath",
3592+
Read(unit_ctx, "extract the enclosing module which can be Required"))),
3593+
(fun mp _ ~depth h c state -> !: ModPath.(MPfile (dp mp)))),
3594+
DocAbove);
3595+
3596+
MLCode(Pred("coq.modtypath->library",
3597+
In(modtypath, "MTP",
3598+
Out(modpath, "LibraryPath",
3599+
Read(unit_ctx, "extract the enclosing module which can be Required"))),
3600+
(fun mtyp _ ~depth h c state -> !: ModPath.(MPfile (dp mtyp)))),
3601+
DocAbove);
3602+
35893603
MLCode(Pred("coq.term->string",
35903604
CIn(failsafe_term,"T",
35913605
Out(B.string, "S",

tests/test_API_env.v

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,11 @@ Elpi Query lp:{{
369369

370370
Set Printing Universes. Print Module Test.
371371
Check Test.f.
372+
373+
From Coq Require Import ZArith.
374+
375+
Elpi Query lp:{{
376+
coq.locate-module "N2Z" MP,
377+
coq.locate-module "Znat" LP,
378+
coq.modpath->library MP LP
379+
}}.

0 commit comments

Comments
 (0)