Skip to content

Commit dd10c3c

Browse files
committed
saturate: honor #[export]
1 parent cc82797 commit dd10c3c

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

HB/instance.elpi

Lines changed: 14 additions & 6 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,
@@ -265,7 +265,11 @@ saturate-instances Filter :- std.do! [
265265

266266
Clauses => std.forall2 TL UKL (t\k\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),
269+
270+
private.clauses-for-export CI 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

HB/structures.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* Support constants, to be kept in sync with shim/structures.v *)
2-
From Corelib Require Import ssreflect ssrfun.
2+
From Coq Require Import ssreflect ssrfun.
33

44
Variant error_msg := NoMsg | IsNotCanonicallyA (x : Type).
55
Definition unify T1 T2 (t1 : T1) (t2 : T2) (s : error_msg) :=

_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

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)