@@ -85,9 +85,9 @@ try-infer-all-args-let Ps T GR X :- std.do! [
8585
8686% [assert!-infer-mixin TheType M Out] infers one mixin M on TheType and
8787% aborts with an error message if the mixin cannot be inferred
88- func assert!-infer-mixin term, mixinname -> term.
89- assert!-infer-mixin T M B :-
90- if (private.mixin-for T M B)
88+ func assert!-infer-mixin term, mixinname -> term, term .
89+ assert!-infer-mixin T M B Ty :-
90+ if (private.mixin-for T M B Ty )
9191 true
9292 (coq.error "HB: cannot inhabit mixin"
9393 {nice-gref->string M} "on"{coq.term->string T}).
@@ -203,8 +203,8 @@ namespace private {
203203
204204% [mixin-for T M MI] synthesizes an instance of mixin M on type T using
205205% the databases [mixin-src] and [from]
206- func mixin-for term, mixinname -> term.
207- mixin-for T M MICompressed :- mixin-src T M Tm, !,
206+ func mixin-for term, mixinname -> term, term .
207+ mixin-for T M MICompressed MICompressedTy :- mixin-src T M Tm, !,
208208 %if-verbose (coq.say {header} "Trying to infer mixin for" M),
209209 std.assert-ok! (coq.typecheck Tm Ty) "mixin-for: Tm illtyped",
210210
@@ -215,12 +215,12 @@ mixin-for T M MICompressed :- mixin-src T M Tm, !,
215215 if (M = Factory)
216216 (
217217 if-verbose (coq.say {header} "Found mixin has type" Factory "on" Subj "no need to apply a builder"),
218- MI = Tm
218+ MI = Tm, MICompressedTy = Ty
219219 )
220220 (
221221 if-verbose (coq.say {header} "Found mixin has type" Factory "on" Subj "hence we apply a builder"),
222222
223- private.builder->term Params T Factory Tm M MI
223+ private.builder->term Params T Factory Tm M MI MITy, MICompressedTy = MITy
224224 % private.builder->term Params T Factory M B,
225225 % coq.subst-fun [Tm] B MI
226226 ),
@@ -254,13 +254,13 @@ compress-coercion-paths MI MICompressed :-
254254 (MI = MICompressed).
255255
256256func mixin-for_mixin-builder prop -> term.
257- mixin-for_mixin-builder (mixin-for _ _ B) B.
257+ mixin-for_mixin-builder (mixin-for _ _ B _ ) B.
258258
259259% [builder->term Params TheType Src Tgt MF] finds a builder from Src to Tgt
260260% and fills in all the mixins required by the builder using mixin-src, obtaining
261261% a function (MF = Builder Params TheType InferredStuff : Src -> Tgt)
262- func builder->term list term, term, factoryname, term, mixinname -> term.
263- builder->term Ps T Src HasSrc Tgt B :- !, std.do! [
262+ func builder->term list term, term, factoryname, term, mixinname -> term, term .
263+ builder->term Ps T Src HasSrc Tgt B1 BTy :- !, std.do! [
264264 from Src Tgt FGR,
265265 F = global FGR,
266266 gref->deps Src MLwP,
@@ -270,7 +270,8 @@ builder->term Ps T Src HasSrc Tgt B :- !, std.do! [
270270 % infer-all-these-mixin-args Ps T ML F B,
271271 coq.mk-n-holes {std.length ML} Holes,
272272 coq.mk-app F {std.flatten [Ps,[T],Holes,[HasSrc]]} B,
273- std.assert-ok! (coq.typecheck B _) "builder illtyped",
273+ std.time (std.assert-ok! (coq.typecheck B BTy) "builder illtyped") _Time1,
274+ B = B1
274275
275276].
276277
@@ -289,7 +290,7 @@ instantiate-all-these-mixin-args (fun _ Tm F) T ML R :-
289290 % factory? Tm (triple _ _ Subj), Subj = T, % check the subject is T (do not pass T to factory?)
290291 !,
291292 if-verbose (coq.say {header} "We have to inhabit it on" T),
292- if (mixin-for T M X) true (coq.error "HB: Unable to find mixin" {nice-gref->string M} "on subject" {coq.term->string T}), !,
293+ if (mixin-for T M X _ ) true (coq.error "HB: Unable to find mixin" {nice-gref->string M} "on subject" {coq.term->string T}), !,
293294 instantiate-all-these-mixin-args (F X) T ML R.
294295instantiate-all-these-mixin-args (fun N Ty F) T ML (fun N Ty FX) :- !,
295296 @pi-decl N Ty m\ instantiate-all-these-mixin-args (F m) T ML (FX m).
@@ -299,7 +300,7 @@ func instantiate-all-args-let term, term -> term, diagnostic.
299300instantiate-all-args-let (fun N Tm F) T (let N Tm X R) Diag :- !, std.do! [
300301 coq.safe-dest-app Tm (global TmGR) _,
301302 factory-alias->gref TmGR M ok,
302- if (mixin-for T M X)
303+ if (mixin-for T M X _ )
303304 (@pi-def N Tm X m\ instantiate-all-args-let (F m) T (R m) Diag)
304305 (Diag = error Msg,
305306 Msg is "cannot synthesize mixin " ^ {nice-gref->string M} ^
@@ -311,7 +312,7 @@ pred try-instantiate-all-args-let i:term, i:term, o:term.
311312try-instantiate-all-args-let (fun N Tm F) T (let N Tm X R) :- !, std.do! [
312313 coq.safe-dest-app Tm (global TmGR) _,
313314 factory-alias->gref TmGR M ok,
314- (mixin-for T M X ; true),
315+ (mixin-for T M X _ ; true),
315316 (@pi-def N Tm X m\ try-instantiate-all-args-let (F m) T (R m)),
316317].
317318try-instantiate-all-args-let F _ F.
0 commit comments