Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions HB/builders.elpi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ begin CtxSkel :-
% "end" is a keyword, be put it in the namespace by hand
func builders.end.
builders.end :- std.do! [
current-mode (builder-from _ _ _ ModName),
current-mode (builder-from T _ _ ModName),

log.coq.env.end-section-name ModName,

Expand All @@ -40,8 +40,10 @@ builders.end :- std.do! [
std.fold LFIL [] builders.private.declare-1-builder Clauses,

if (Clauses = [])
(coq.error "No builders to declare, did you forget HB.instance?")
true,
(coq.error "HB:"
{ calc ("No builders on " ^ { coq.term->string T } ^ " to declare.") }
{ calc ("This HB.builders section must HB.instance at least one mixin or factory on " ^ { coq.term->string T } ^ ".") }
) true,

std.findall (abbrev-to-export F_ N_ A_) ExportClauses,
coq.env.current-path CurModPath,
Expand Down
11 changes: 9 additions & 2 deletions HB/instance.elpi
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,19 @@ func declare-instance factoryname, term, term
declare-instance Factory T F Clauses CFL CSL :-
current-mode (builder-from T TheFactory FGR _), !,
if (get-option "local" tt)
(coq.error "HB: declare-instance: cannot make builders local.
If you want temporary instances, make an alias, e.g. with let T' := T") true,
(coq.error "HB:" "declare-instance: cannot make builders local."
{ calc ("If you want temporary instances, make an alias, e.g. with let " ^ { coq.term->string T } ^ "' := " ^ { coq.term->string T } ) }
)
true,
!,
declare-canonical-instances-from-factory-and-local-builders Factory
T F TheFactory FGR Clauses CFL CSL.
declare-instance Factory T F Clauses CFL CSL :-
if (not (get-option "local" tt),
current-mode (builder-from U _ _ _), not (T = U))
(coq.warning "HB" "HB.nonlocal-instance-in-builder-mode"
"In builder mode, non-builder instances are always considered local.\n"
"Annotate this HB.instance call with #[local] to fix this warning and improve your code documentation.") true,
declare-canonical-instances-from-factory Factory T F Clauses1 CFL CSL,
if (get-option "export" tt)
(coq.env.current-library File,
Expand Down
Loading