Skip to content

Commit 7c65a67

Browse files
committed
changing mk-phant-abbrev to use skeletons
1 parent f6fd7ec commit 7c65a67

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

hb.elpi

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,9 @@ mk-phant-abbrev.term K F [unify-arg|AL] K' FAbbrev :- !,
946946
mk-phant-abbrev.term K {mk-app F [{{lib:@hb.id _ _}}]} AL K' FAbbrev.
947947

948948
pred mk-phant-abbrev i:string, i:phant-term, o:constant, o:abbreviation.
949-
mk-phant-abbrev N (phant-term AL T) C Abbrev :- std.do! [
949+
mk-phant-abbrev N (phant-term AL T1) C Abbrev :- std.do! [
950950
NC is "phant_" ^ N,
951-
std.assert-ok! (coq.typecheck T TTy) "mk-phant-abbrev: T illtyped",
951+
std.assert-ok! (coq.elaborate-skeleton T1 TTy T) "mk-phant-abbrev: T illtyped",
952952
hb-add-const NC T TTy @transparent! C,
953953
mk-phant-abbrev.term 0 (global (const C)) AL NParams AbbrevT,
954954
@global! => coq.notation.add-abbreviation N NParams AbbrevT tt Abbrev,
@@ -1657,20 +1657,21 @@ pack-body ClassName PL T MLwA F :- std.do! [
16571657

16581658
pred declare-auto-infer-params-abbrev i:structure, i:list-w-params mixinname.
16591659
declare-auto-infer-params-abbrev GR MLwP :- get-option "infer" Map, !,
1660-
Map => mk-infer (global GR) MLwP PHARGS TSK,
1661-
std.assert-ok! (coq.elaborate-skeleton TSK _ T) "infer illtyped",
1662-
mk-phant-abbrev "type" (phant-term PHARGS T) _ _.
1660+
Map => mk-infer (global GR) MLwP PHT,
1661+
mk-phant-abbrev "type" PHT _ _.
16631662
declare-auto-infer-params-abbrev _ _.
16641663

1665-
pred mk-infer i:term, i:list-w-params mixinname, o:list phant-arg, o:term.
1666-
mk-infer T (w-params.nil _ _ _) [] T.
1667-
mk-infer T (w-params.cons N Ty W) [implicit-arg, infer-type N|A] R1 :- coq.name->id N ID, (get-option ID "Type" ; get-option ID ""), !,
1664+
pred mk-infer i:term, i:list-w-params mixinname, o:phant-term.
1665+
mk-infer T (w-params.nil _ _ _) (phant-term [] T).
1666+
mk-infer T (w-params.cons N Ty W) (phant-term [implicit-arg, infer-type N|A] R1) :-
1667+
coq.name->id N ID, (get-option ID "Type" ; get-option ID ""), !,
16681668
R1 = (fun N Ty n\ fun `ph` {{ lib:@hb.phant lp:n }} _\ R n),
16691669
@pi-decl N Ty n\
1670-
mk-infer {mk-app T [n]} (W n) A (R n).
1671-
mk-infer T (w-params.cons N Ty W) [real-arg N|A] (fun N Ty R) :- coq.name->id N ID, not (get-option ID _), !,
1672-
@pi-decl N Ty x\ mk-infer {mk-app T [x]} (W x) A (R x).
1673-
mk-infer _ (w-params.cons N _ _) _ _ :- coq.name->id N ID, get-option ID Infer,
1670+
mk-infer {mk-app T [n]} (W n) (phant-term A (R n)).
1671+
mk-infer T (w-params.cons N Ty W) (phant-term [real-arg N|A] (fun N Ty R)) :-
1672+
coq.name->id N ID, not (get-option ID _), !,
1673+
@pi-decl N Ty x\ mk-infer {mk-app T [x]} (W x) (phant-term A (R x)).
1674+
mk-infer _ (w-params.cons N _ _) _ :- coq.name->id N ID, get-option ID Infer,
16741675
coq.error "Automatic inference of paramter" N "from" Infer "not supported".
16751676

16761677
% HB.structure Definition S P1 P2 := { T of F1 P1 T & F2 P1 (P2*P2) T }

0 commit comments

Comments
 (0)