@@ -92,7 +92,10 @@ fun-infer-type funclass N Ty (t\private.phant-term AL (Bo t)) Out :-
9292 coq.name-suffix N "ph" PhN,
9393 fun-implicit N Ty (t\private.phant-term [private.infer-type N funclass|AL]
9494 (fun PhN {{ lib:@hb.phantom (_ -> _) lp:t }} _\ Bo t)) Out.
95- fun-infer-type C _ _ _ _ :- coq.error "HB: inference of parameters of call" C "not implemented yet".
95+ fun-infer-type (grefclass Class) N Ty (t\private.phant-term AL (Bo t)) Out :-
96+ coq.name-suffix N "ph" PhN, private.build-type-pattern Class Pat,
97+ fun-implicit N Ty (t\private.phant-term [private.infer-type N (grefclass Class)|AL]
98+ (fun PhN {{ lib:@hb.phantom lp:Pat lp:t }} _\ Bo t)) Out.
9699
97100% TODO: this looks like a hack to remove
98101pred append-fun-unify i:phant-term, o:phant-term.
@@ -180,12 +183,25 @@ build-abbreviation K F [infer-type N sortclass|AL] K'' (fun N _ AbbrevFx) :- !,
180183build-abbreviation K F [infer-type N funclass|AL] K'' (fun N _ AbbrevFx) :- !,
181184 pi x\ build-abbreviation K {mk-app F [{{ lib:hb.Phantom (_ -> _) lp:x }}]} AL K' (AbbrevFx x),
182185 K'' is K' + 1.
183- build-abbreviation _ _ [infer-type _ (grefclass _)|_] _ _ :- coq.error "TODO".
186+ build-abbreviation K F [infer-type N (grefclass Class)|AL] K'' (fun N _ AbbrevFx) :- !,
187+ build-type-pattern Class Pat,
188+ pi x\ build-abbreviation K {mk-app F [{{ lib:hb.Phantom lp:Pat lp:x }}]} AL K' (AbbrevFx x),
189+ K'' is K' + 1.
184190build-abbreviation K F [implicit|AL] K' FAbbrev :- !,
185191 build-abbreviation K {mk-app F [_]} AL K' FAbbrev.
186192build-abbreviation K F [unify|AL] K' FAbbrev :- !,
187193 build-abbreviation K {mk-app F [{{lib:@hb.id _ _}}]} AL K' FAbbrev.
188194
195+ % [build-type-pattern GR Pat] cheks that GR : forall x_1 ... x_n, Type
196+ % and returns Pat = GR _ ... _ (that is GR applied to n holes).
197+ % Note that n can be 0 when GR : Type.
198+ pred build-type-pattern i:gref, o:term.
199+ build-type-pattern GR Pat :- build-type-pattern.aux GR {coq.env.typeof GR} Pat.
200+ build-type-pattern.aux GR T {{ lp:Pat _ }} :- coq.unify-eq T (prod N S T') ok, !,
201+ @pi-decl N S x\ build-type-pattern.aux GR (T' x) Pat.
202+ build-type-pattern.aux GR T (global GR) :- coq.unify-eq T {{ Type }} ok, !.
203+ build-type-pattern.aux _ _ _ :- coq.error "HB: wrong carrier type".
204+
189205
190206% [mk-phant-term F PF] states that
191207% if F = fun p1 .. p_k T m_0 .. m_n => _
0 commit comments