Skip to content

Commit ccd9a32

Browse files
committed
Make first argument optional
1 parent 419e824 commit ccd9a32

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

HB/howto.elpi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ main-str S STgt Depth :- coq.locate S GR, main-gref GR STgt Depth.
1212
pred main-gref i:gref, i:string, i:int.
1313
main-gref GR STgt Depth :-
1414
private.mixins-on-gref GR MLSrc,
15+
main-from MLSrc STgt Depth.
16+
17+
pred main-from i:list mixinname, i:string, i:int.
18+
main-from MLSrc STgt Depth :-
1519
private.mixins-in-string STgt MLTgt,
1620
private.list-diff MLTgt MLSrc ML,
1721
if (ML = []) (coq.say "HB: nothing to do.")

structures.v

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ Elpi Export HB.about.
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.
306+
The first argument [T] is optional, when ommited [Foo.type] is built
307+
from scratch.
306308
*)
307309

308310
#[arguments(raw)] Elpi Command HB.howto.
@@ -325,8 +327,12 @@ main [str T, str STgt] :- !,
325327
with-attributes (with-logging (howto.main-str T STgt 3)).
326328
main [str T, str STgt, int Depth] :- !,
327329
with-attributes (with-logging (howto.main-str T STgt Depth)).
330+
main [str STgt] :- !,
331+
with-attributes (with-logging (howto.main-from [] STgt 3)).
332+
main [str STgt, int Depth] :- !,
333+
with-attributes (with-logging (howto.main-from [] STgt Depth)).
328334

329-
main _ :- coq.error "Usage: HB.howto (<type>) <structure> [<search depth>].".
335+
main _ :- coq.error "Usage: HB.howto [(<type>)] <structure> [<search depth>].".
330336
}}.
331337
Elpi Typecheck.
332338
Elpi Export HB.howto.

tests/howto.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ From Coq Require Import ZArith ssrfun ssreflect.
22
From HB Require Import structures.
33
From HB Require Import demo1.hierarchy_5.
44

5+
HB.howto Ring.type.
6+
7+
HB.howto Ring.type 2.
8+
59
HB.howto Z Ring.type.
610

711
HB.howto Z Ring.type 2.

tests/howto.v.out

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ HB: solutions (use 'HB.about F.Build' to see the arguments of each factory F):
1818
- AddAG_of_TYPE; SemiRing_of_AddComoid
1919
- AddComoid_of_TYPE; Ring_of_AddComoid
2020

21+
HB: solutions (use 'HB.about F.Build' to see the arguments of each factory F):
22+
- Ring_of_TYPE
23+
- AddAG_of_TYPE; BiNearRing_of_AddMonoid
24+
- AddAG_of_TYPE; Ring_of_AddAG
25+
- AddAG_of_TYPE; SemiRing_of_AddComoid
26+
- AddComoid_of_TYPE; Ring_of_AddComoid
27+
- AddComoid_of_TYPE; AddAG_of_AddComoid; BiNearRing_of_AddMonoid
28+
- AddComoid_of_TYPE; AddAG_of_AddComoid; Ring_of_AddAG
29+
- AddComoid_of_TYPE; AddAG_of_AddComoid; SemiRing_of_AddComoid
30+
- AddComoid_of_TYPE; BiNearRing_of_AddMonoid; AddAG_of_AddComoid
31+
- AddComoid_of_TYPE; SemiRing_of_AddComoid; AddAG_of_AddComoid
32+
- AddMonoid_of_TYPE; AddComoid_of_AddMonoid; Ring_of_AddComoid
33+
34+
HB: solutions (use 'HB.about F.Build' to see the arguments of each factory F):
35+
- Ring_of_TYPE
36+
- AddAG_of_TYPE; BiNearRing_of_AddMonoid
37+
- AddAG_of_TYPE; Ring_of_AddAG
38+
- AddAG_of_TYPE; SemiRing_of_AddComoid
39+
- AddComoid_of_TYPE; Ring_of_AddComoid
40+
2141
The command has indeed failed with message:
2242
HB: no solution found, try to increase search depth.
2343
HB: solutions (use 'HB.about F.Build' to see the arguments of each factory F):

0 commit comments

Comments
 (0)