Skip to content

Commit 062b169

Browse files
authored
Merge pull request #564 from math-comp/saturate-export
saturate: honor #[export]
2 parents cc82797 + 6f62e00 commit 062b169

File tree

6 files changed

+48
-10
lines changed

6 files changed

+48
-10
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
coq_version:
2121
- '8.20'
2222
- '9.0'
23-
#- '9.1'
23+
- '9.1'
2424
steps:
2525
- uses: actions/checkout@v2
2626
- uses: coq-community/docker-coq-action@v1

.nix/coq-nix-toolbox.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"7af8a21e712b7665447bea5189ce3ff83fcfeac8"
1+
"f21be9b79484884fb23d06463c6f03cb2a266b8b"

HB/instance.elpi

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ mk-factory-sort-factory AliasGR CFL CSL :- std.do! [
250250
].
251251

252252
% create instances for all possible combinations of types and structure compatible
253-
func saturate-instances cs-pattern ->.
253+
func saturate-instances cs-pattern -> .
254254
saturate-instances Filter :- std.do! [
255255

256256
findall-has-mixin-instance Filter ClausesHas,
@@ -263,9 +263,13 @@ saturate-instances Filter :- std.do! [
263263

264264
std.map ClausesHas has-mixin-instance->mixin-src Clauses,
265265

266-
Clauses => std.forall2 TL UKL (t\k\sigma Classes\
266+
Clauses => std.map2 TL UKL (t\k\CI\sigma Classes\
267267
std.filter AllClasses (no-instance-for k) Classes,
268-
declare-all-on-type-constructor t Classes _),
268+
declare-all-on-type-constructor t Classes CI) CIL,
269+
270+
private.clauses-for-export {std.flatten CIL} ClausesExport,
271+
272+
acc-clauses current ClausesExport,
269273
].
270274

271275
func no-instance-for cs-pattern, hbclass ->.
@@ -293,11 +297,15 @@ declare-instance Factory T F Clauses CFL CSL :-
293297
T F TheFactory FGR Clauses CFL CSL.
294298
declare-instance Factory T F Clauses CFL CSL :-
295299
declare-canonical-instances-from-factory Factory T F Clauses1 CFL CSL,
296-
if (get-option "export" tt)
300+
clauses-for-export {std.append CFL CSL} Clauses2,
301+
std.append Clauses1 Clauses2 Clauses.
302+
303+
func clauses-for-export list (pair id constant) -> list prop.
304+
clauses-for-export CL ECL :-
305+
if (get-option "export" tt)
297306
(coq.env.current-library File,
298-
std.map {std.append CFL CSL} (x\r\ sigma i c\ x = pr i c, r = instance-to-export File i c) Clauses2)
299-
(Clauses2 = []),
300-
std.append Clauses1 Clauses2 Clauses.
307+
std.map CL (x\r\ sigma i c\ x = pr i c, r = instance-to-export File i c) ECL)
308+
(ECL = []).
301309

302310
% [add-mixin T F _ M Cl] adds a constant being the mixin instance for M on type
303311
% T built from factory F

_CoqProject.test-suite

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ tests/unit/struct.v
6060
tests/factory_when_notation.v
6161

6262
tests/saturate_on.v
63+
tests/saturate_export.v
6364
tests/bug_435.v
6465
tests/bug_447.v
6566

rocq-hierarchy-builder.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build: [ [ make "build"]
1414
install: [ make "install" ]
1515
depends: [
1616
("coq" {>= "8.20" & < "8.21~"} & "coq-elpi" {>= "3" | = "dev"}
17-
| "rocq-core" {(>= "9.0" & < "9.1~") | = "dev"} & "rocq-elpi" {>= "3" | = "dev"})
17+
| "rocq-core" {(>= "9.0" & < "9.2~") | = "dev"} & "rocq-elpi" {>= "3" | = "dev"})
1818
]
1919
conflicts: [
2020
"coq-hierarchy-builder" {< "1.9~"}

tests/saturate_export.v

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From HB Require Import structures.
2+
3+
HB.mixin Record HasPoint T := { default : T }.
4+
5+
HB.instance Definition _ : HasPoint nat := HasPoint.Build nat 0.
6+
HB.instance Definition _ : HasPoint bool := HasPoint.Build bool false.
7+
HB.instance Definition _ A : HasPoint (list A) := HasPoint.Build (list A) nil.
8+
HB.instance Definition _ A : HasPoint Type := HasPoint.Build Type nat.
9+
10+
HB.structure Definition Pointed := { T of HasPoint T }.
11+
12+
Fail Check (list unit : Pointed.type).
13+
14+
Module Foo.
15+
HB.saturate (list _).
16+
Module E. HB.reexport. End E.
17+
End Foo.
18+
19+
Import Foo.E.
20+
Fail Check (list unit : Pointed.type).
21+
22+
Module Bar.
23+
#[export]
24+
HB.saturate (list _).
25+
Module E. HB.reexport. End E.
26+
End Bar.
27+
28+
Import Bar.E.
29+
Check (list unit : Pointed.type).

0 commit comments

Comments
 (0)