@@ -129,9 +129,14 @@ pred phant-abbrev o:gref, o:gref, o:abbreviation.
129129% [factory-alias->gref X GR] when X is already a factory X = GR
130130% however, when X is a phantom abbreviated gref, we find the underlying
131131% factory gref GR associated to it.
132- pred factory-alias->gref i:gref, o:gref.
133- factory-alias->gref PhGR GR :- phant-abbrev GR PhGR _, !.
134- factory-alias->gref GR GR :- phant-abbrev GR _ _, !.
132+ pred factory-alias->gref i:gref, o:gref, o: diagnostic.
133+ factory-alias->gref PhGR GR ok :- phant-abbrev GR PhGR _, !.
134+ factory-alias->gref GR GR ok :- phant-abbrev GR _ _, !.
135+ factory-alias->gref GR _ (error Msg) :- !,
136+ Msg is {coq.term->string (global GR)} ^
137+ " is not a factory or its library (" ^
138+ { std.string.concat "." {std.drop-last 1 {coq.gref->path GR} } } ^
139+ ") was not correctly imported".
135140
136141%%%%% Cache of known facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137142
@@ -230,6 +235,7 @@ pred current-mode o:declaration.
230235pred module-to-export o:string, o:id, o:modpath.
231236pred instance-to-export o:string, o:id, o:constant.
232237pred abbrev-to-export o:string, o:id, o:gref.
238+ pred clause-to-export o:string, o:prop.
233239
234240%% database for HB.locate and HB.about %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
235241
@@ -268,7 +274,7 @@ Elpi Accumulate lp:{{
268274main [str S] :- !,
269275 if (decl-location {coq.locate S} Loc)
270276 (coq.say "HB: synthesized in file" Loc)
271- (coq.say "HB: " S "not synthesized by HB").
277+ (coq.say "HB" S "not synthesized by HB").
272278
273279main _ :- coq.error "Usage: HB.locate <name>.".
274280}}.
@@ -482,7 +488,7 @@ actions N :-
482488 coq.elpi.accumulate current "export.db" (clause _ _ (module-to-export File E)).
483489
484490main [indt-decl D] :- record-decl->id D N, with -attributes (actions N).
485-
491+
486492main _ :-
487493 coq.error "Usage: HB.mixin Record <MixinName> T of F A & … := { … }.".
488494}}.
@@ -495,7 +501,7 @@ Elpi Export HB.mixin.
495501
496502(** [HB.pack] and [HB.pack_for] are tactic-in-term synthesizing a structure
497503 instance.
498-
504+
499505 In the middle of a term, in a context expecting a [Structure.type],
500506 you can write [HB.pack T F] to use factory [F] to equip type [T] with
501507 [Structure]. If [T] is already a rich type, eg [T : OtherStructure.type]
@@ -504,7 +510,7 @@ Elpi Export HB.mixin.
504510
505511 If the context does not impose a [Structure.type] typing constraint, then
506512 you can use [HB.pack_for Structure.type T F].
507-
513+
508514 You can pass zero or more factories like [F] but they must all typecheck
509515 in the current context (the type is not enriched progressively).
510516 Structure instances are projected to their class in order to obtain a
@@ -645,7 +651,7 @@ Elpi Accumulate lp:{{
645651main [const-decl N (some B) Arity] :- std.do! [
646652 % compute the universe for the structure (default )
647653 prod-last {coq.arity->term Arity} Ty,
648- if (ground_term Ty) (Sort = Ty) (Sort = {{Type }}), sort Univ = Sort,
654+ if (ground_term Ty) (Sort = Ty) (Sort = {{Type }}), sort Univ = Sort,
649655 with -attributes (with -logging (structure.declare N B Univ)),
650656].
651657
@@ -686,7 +692,7 @@ actions-compat ModuleName :-
686692 true.
687693
688694main [const-decl N _ _] :- !, with -attributes (actions N).
689-
695+
690696main _ :- coq.error "Usage: HB.structure Definition <ModuleName> := { A of <Factory1> A & … & <FactoryN> A }".
691697}}.
692698Elpi Typecheck.
@@ -839,7 +845,7 @@ actions N :-
839845
840846main [indt-decl D] :- record-decl->id D N, with -attributes (actions N).
841847main [const-decl N _ _] :- with-attributes (actions N).
842-
848+
843849main _ :-
844850 coq.error "Usage: HB.factory Record <FactoryName> T of F A & … := { … }.\nUsage: HB.factory Definition <FactoryName> T of F A := t.".
845851}}.
@@ -916,7 +922,7 @@ actions N :-
916922 begin-section N.
917923
918924main [ctx-decl _] :- !, with -attributes (actions {calc ("Builders_" ^ {std.any->string {new_int} })}).
919-
925+
920926main _ :- coq.error "Usage: HB.builders Context A (f : F1 A).".
921927}}.
922928Elpi Typecheck.
@@ -1208,5 +1214,5 @@ Notation "`Error_cannot_unify: t1 'with' t2" := (unify t1 t2 None)
12081214Notation "`Error: t msg T" := (unify t _ (Some (msg%string, T)))
12091215 (at level 0, msg, T at level 0, format "`Error: t msg T", only printing) :
12101216 form_scope.
1211-
1217+
12121218Global Open Scope string_scope.
0 commit comments