Skip to content

Commit 419e824

Browse files
committed
Accept both term and string input
1 parent 477518e commit 419e824

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

HB/howto.elpi

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33

44
namespace howto {
55

6-
pred main i:string, i:string, i:int.
7-
main ST STgt Depth :-
8-
private.mixins-on-string ST MLSrc,
6+
pred main-trm i:term, i:string, i:int.
7+
main-trm T STgt Depth :- coq.term->gref T GR, main-gref GR STgt Depth.
8+
9+
pred main-str i:string, i:string, i:int.
10+
main-str S STgt Depth :- coq.locate S GR, main-gref GR STgt Depth.
11+
12+
pred main-gref i:gref, i:string, i:int.
13+
main-gref GR STgt Depth :-
14+
private.mixins-on-gref GR MLSrc,
915
private.mixins-in-string STgt MLTgt,
1016
private.list-diff MLTgt MLSrc ML,
1117
if (ML = []) (coq.say "HB: nothing to do.")
@@ -49,13 +55,12 @@ lexi-order [] [].
4955
lexi-order [X1|_] [X2|_] :- lt-gref X1 X2.
5056
lexi-order [X|T1] [X|T2] :- lexi-order T1 T2.
5157

52-
% [mixins-on-string S ML] list mixins in structures [S] is equipped with
53-
pred mixins-on-string i:string, o:list mixinname.
54-
mixins-on-string S ML :-
55-
coq.locate S GR,
58+
% [mixins-on-gref GR ML] list mixins in structures [GR] is equipped with
59+
pred mixins-on-gref i:gref, o:list mixinname.
60+
mixins-on-gref GR ML :-
5661
std.filter {coq.CS.db-for _ (cs-gref GR)} (about.not1 about.unif-hint?) LV,
57-
std.fold LV [] mixins-on-string.aux ML.
58-
mixins-on-string.aux (cs-instance _ _ GR) L L' :-
62+
std.fold LV [] mixins-on-gref.aux ML.
63+
mixins-on-gref.aux (cs-instance _ _ GR) L L' :-
5964
coq.prod-tgt->gref {coq.env.typeof GR} F,
6065
class-def (class _ F MLWP),
6166
union L {list-w-params_list MLWP} L'.

structures.v

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ Elpi Export HB.about.
299299
(* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% *)
300300
(* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% *)
301301

302-
(** [HB.howto T Foo.type d] prints possible sequences of factories
302+
(** [HB.howto (T) Foo.type d] prints possible sequences of factories
303303
to equip a type [T] with a structure [Foo.type], taking into account
304304
structures already instantiated on [T]. The search depth [d]
305305
is the maximum length of the sequences, 3 by default.
@@ -317,12 +317,16 @@ Elpi Accumulate File "HB/howto.elpi".
317317
Elpi Accumulate Db hb.db.
318318
Elpi Accumulate lp:{{
319319

320-
main [str ST, str STgt] :- !,
321-
with-attributes (with-logging (howto.main ST STgt 3)).
322-
main [str ST, str STgt, int Depth] :- !,
323-
with-attributes (with-logging (howto.main ST STgt Depth)).
320+
main [trm T, str STgt] :- !,
321+
with-attributes (with-logging (howto.main-trm T STgt 3)).
322+
main [trm T, str STgt, int Depth] :- !,
323+
with-attributes (with-logging (howto.main-trm T STgt Depth)).
324+
main [str T, str STgt] :- !,
325+
with-attributes (with-logging (howto.main-str T STgt 3)).
326+
main [str T, str STgt, int Depth] :- !,
327+
with-attributes (with-logging (howto.main-str T STgt Depth)).
324328

325-
main _ :- coq.error "Usage: HB.howto <type> <structure> [<search depth>].".
329+
main _ :- coq.error "Usage: HB.howto (<type>) <structure> [<search depth>].".
326330
}}.
327331
Elpi Typecheck.
328332
Elpi Export HB.howto.

0 commit comments

Comments
 (0)