@@ -1457,6 +1457,16 @@ if-class-already-exists-error N [class _ S ML1wP|CS] ML2 :-
14571457 (coq.error "Structure" {coq.term->string S} "contains the same mixins of" N)
14581458 (if-class-already-exists-error N CS ML2).
14591459
1460+ pred export-mixin-coercion i:classname, i:option constant.
1461+ export-mixin-coercion _ none.
1462+ export-mixin-coercion ClassName (some C) :-
1463+ coq.env.typeof (const C) CTy,
1464+ safe-dest-app {safe-head CTy} Mixin _,
1465+ coq.term->gref Mixin MixinGR,
1466+ if-verbose (coq.say "export-mixin-coercion: from" ClassName "to" MixinGR),
1467+ @global! =>
1468+ coq.coercion.declare (coercion (const C) _ ClassName (grefclass MixinGR)).
1469+
14601470% HB.structure Definition S P1 P2 := { T of F1 P1 T & F2 P1 (P2*P2) T }
14611471% cons p1\ cons p2\ nil t\ [triple f1 [p1] t,triple f2 [p1, {{p1 * p2}}] t]
14621472pred main-declare-structure i:string, i:list-w-params gref, i:bool.
@@ -1508,6 +1518,14 @@ main-declare-structure Module GRFSwP ClosureCheck :- std.do! [
15081518 declare-unification-hints SortProjection ClassProjection CurrentClass NewJoins,
15091519 % Register in Elpi's DB the new structure
15101520 % NOT TODO: All these acc are correctly locaed in an Export Module
1521+
1522+ if (ClassName = indt ClassInd) (std.do![
1523+ if-verbose (coq.say "HB: exporting coercions from class to mixins"),
1524+ std.forall {coq.CS.canonical-projections ClassInd}
1525+ (export-mixin-coercion ClassName)
1526+ ])
1527+ (coq.say "declare-structure:" ClassName "should be an inductive", fail),
1528+
15111529 if-verbose (coq.say "HB: accumulating various props"),
15121530 std.forall MLToExport (m\ acc current (clause _ _ (mixin-first-class m ClassName))),
15131531 std.forall EX (ex\ acc current (clause _ _ ex)),
@@ -1698,7 +1716,7 @@ is-last-named-asset-param (asset-parameter _ _ _\ asset-alias _ _) :- !.
16981716
16991717% main-declare-asset Asset AssetKind
17001718pred main-declare-asset i:asset-decl, i:asset.
1701- main-declare-asset Asset AssetKind :-
1719+ main-declare-asset Asset AssetKind :-
17021720 % since we turn locally bound variables into global constrants the holes
17031721 % in the input term can go outside the pattern fragment, but we don't care
17041722 @holes! => std.do! [
0 commit comments