Skip to content

Commit d916430

Browse files
committed
little optimization
1 parent d0e8e0d commit d916430

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

hb.elpi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ if-MC-compat P :- get-option "mathcomp.axiom" S, !,
104104
P (some GR).
105105
if-MC-compat _.
106106

107-
108-
109107
% TODO: Should this only be used for gref that are factories? (and check in the first/second branch so?)
110108
% Should we make this an HO predicate, eg "located->gref S L is-factory? GR"
111109
pred located->gref i:string, i:list located, o:gref.
@@ -116,10 +114,6 @@ located->gref S [loc-modpath _|_] _ :- coq.error S "should be a factory, but is
116114
located->gref S [loc-modtypath _|_] _ :- coq.error S "should be a factory, but is a module type".
117115
located->gref S [] _ :- coq.error "Could not locate name" S.
118116

119-
pred purge-id i:term, o:term.
120-
purge-id T T1 :-
121-
(pi fresh t v\ copy {{lib:@hb.id lp:t lp:v}} fresh :- !) => copy T T1.
122-
123117
% TODO: generalize/rename when we support parameters
124118
pred argument->gref i:argument, o:gref.
125119
argument->gref (str S) GR :- located->gref S {coq.locate-all S} GR.
@@ -700,7 +694,7 @@ phant-fun-struct T Name S Params PF Out :- std.do! [
700694
mk-app (global S) Params SParams,
701695
mk-app SortProj Params SortProjParams,
702696
% Msg = {{lib:hb.nomsg}},
703-
Msg = {{lib:hb.some (lib:hb.pair "is not canonically a"%string lp:SParams)}},
697+
Msg = {{lib:hb.some (lib:hb.pair lib:hb.not_a_msg lp:SParams)}},
704698
(@pi-decl Name SParams s\ phant-fun-unify Msg T {mk-app SortProjParams [s]} (PF s) (UnifSI s)),
705699
phant-fun-implicit Name SParams UnifSI Out
706700
].

structures.v

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ Definition unify T1 T2 (t1 : T1) (t2 : T2) (s : option (string * Type)) :=
77
phantom T1 t1 -> phantom T2 t2.
88
Definition id_phant {T} {t : T} (x : phantom T t) := x.
99
Definition nomsg : option (string * Type) := None.
10+
Definition is_not_canonically_a : string := "is not canonically a".
1011

1112
Register unify as hb.unify.
1213
Register id_phant as hb.id.
1314
Register Coq.Init.Datatypes.None as hb.none.
1415
Register nomsg as hb.nomsg.
16+
Register is_not_canonically_a as hb.not_a_msg.
1517
Register Coq.Init.Datatypes.Some as hb.some.
1618
Register Coq.Init.Datatypes.pair as hb.pair.
1719
Register Coq.Init.Datatypes.prod as hb.prod.
@@ -508,6 +510,9 @@ Elpi Typecheck.
508510
Notation "`Error_cannot_unify: t1 'with' t2" := (unify t1 t2 None)
509511
(at level 0, format "`Error_cannot_unify: t1 'with' t2", only printing) :
510512
form_scope.
513+
Notation "`Error: t `is_not_canonically_a T" := (unify t _ (Some (is_not_canonically_a, T)))
514+
(at level 0, T at level 0, format "`Error: t `is_not_canonically_a T", only printing) :
515+
form_scope.
511516
Notation "`Error: t msg T" := (unify t _ (Some (msg%string, T)))
512517
(at level 0, msg, T at level 0, format "`Error: t msg T", only printing) :
513518
form_scope.

0 commit comments

Comments
 (0)