Skip to content

Commit 0ce37f5

Browse files
committed
wip: infer(P = "_ -> _")
1 parent afa48b8 commit 0ce37f5

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

HB/common/utils.elpi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ w-params.fold.params (w-params.cons ID PTy F) Cons Nil RevPs Out :- !, std.do! [
158158
coq.id->name ID N,
159159
(@pi-decl N PTy p\ w-params.fold.params (F p) Cons Nil [p|RevPs] (Body p)),
160160
Cons N PTy Body Out].
161-
w-params.fold.params (w-params.nil ID TTy F) _ Nil RevParams Out :- !,
161+
w-params.fold.params (w-params.nil ID TTy F) _ Nil RevParams Out :- !, std.do! [
162162
coq.id->name ID N,
163-
std.rev RevParams Params, !, Nil Params N TTy F Out.
163+
std.rev RevParams Params,
164+
Nil Params N TTy F Out,
165+
].
164166

165167
% [w-params.then AwP Cons Nil Out] states that Out has shape
166168
% Cons `x_1` T_1 p_1 \ .. \ Nil [p_1 .. p_n] `T` Ty t \ Body

HB/structure.elpi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ mk-infer T (w-params.nil _ _ _) PH :- phant.init T PH.
542542
mk-infer T (w-params.cons ID Ty W) R :- (get-option ID "Type" ; get-option ID ""), !,
543543
@pi-parameter ID Ty t\ mk-infer {mk-app T [t]} (W t) (PhT t),
544544
phant.fun-infer-type sortclass {coq.id->name ID} Ty PhT R.
545+
mk-infer T (w-params.cons ID Ty W) R :- (get-option ID "_ -> _"), !,
546+
@pi-parameter ID Ty t\ mk-infer {mk-app T [t]} (W t) (PhT t),
547+
phant.fun-infer-type funclass {coq.id->name ID} Ty PhT R.
545548
mk-infer T (w-params.cons ID Ty W) R :- not (get-option ID _), !,
546549
@pi-parameter ID Ty t\ mk-infer {mk-app T [t]} (W t) (PhT t),
547550
phant.fun-real {coq.id->name ID} Ty PhT R.

structures.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Elpi Accumulate File "HB/structure.elpi".
336336
Elpi Accumulate Db hb.db.
337337
Elpi Accumulate lp:{{
338338

339-
main [const-decl N (some B) _] :- with-attributes (structure.declare N B).
339+
main [const-decl N (some B) _] :- !, with-attributes (structure.declare N B).
340340
main _ :- coq.error "Usage: HB.structure Definition <ModuleName> := { A of <Factory1> A & … & <FactoryN> A }".
341341
}}.
342342
Elpi Typecheck.

tests/funclass.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ HB.instance Definition x5 :=
5050

5151
Check Monoid.on mult.
5252

53+
54+
HB.mixin Record silly T := { xx : T }.
55+
#[verbose, infer(F = "_ -> _")]
56+
HB.structure Definition wp T (F : Monoid.type T) := { A of silly A }.
57+
58+
Check forall w : wp.type mult, w = w.
59+

0 commit comments

Comments
 (0)