Skip to content

Commit ac1869f

Browse files
committed
use -> for functions and remove once
1 parent c6b44ee commit ac1869f

File tree

13 files changed

+162
-98
lines changed

13 files changed

+162
-98
lines changed

HB/about.elpi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ main-located _ (loc-gref Class) :- class-def (class Class GR MLwP), !,
2020
S is M ^ "." ^ St,
2121
private.main-structure S Class GR MLwP.
2222

23-
main-located S (loc-gref (indt I)) :- factory-constructor (indt I) _, !,
23+
main-located S (loc-gref (indt I)) :- factory->constructor (indt I) _, !,
2424
private.main-factory S I.
2525

26-
main-located S (loc-gref (const C)) :- factory-constructor (const C) _, !,
26+
main-located S (loc-gref (const C)) :- factory->constructor (const C) _, !,
2727
private.main-factory-alias S C.
2828

2929
main-located S (loc-gref (const C)) :- exported-op M _ C, !,
@@ -32,8 +32,8 @@ main-located S (loc-gref (const C)) :- exported-op M _ C, !,
3232
main-located S (loc-gref GR) :- factory-alias->gref GR F ok, not (F = GR), !,
3333
main-located S (loc-gref F).
3434

35-
main-located S (loc-abbreviation A) :- phant-abbrev GR PhB A, factory-constructor (indt F) GR, !,
36-
private.main-factory-constructor S F PhB GR.
35+
main-located S (loc-abbreviation A) :- phant-abbrev GR PhB A, factory->constructor (indt F) GR, !,
36+
private.main-factory->constructor S F PhB GR.
3737

3838
main-located S (loc-abbreviation A) :-
3939
coq.notation.abbreviation-body A NArgs _,
@@ -170,7 +170,7 @@ main-coercion S [coercion GR _ Src Tgt|_] :-
170170
func main-operation string, mixinname, constant -> .
171171
main-operation S MixinSource _ :-
172172
% fetch
173-
mixin-first-class MixinSource Class,
173+
mixin->first-class MixinSource Class,
174174
class-def (class Class Structure _), !,
175175
% format
176176
PpOriginStructure = box (hov 4) [
@@ -189,7 +189,7 @@ main-structure S Class Structure MLwP :-
189189
% fetch
190190
list-w-params_list MLwP ML,
191191
std.map-filter ML (m\r\ sigma P O OPS\
192-
std.once (mixin-first-class m Class),
192+
mixin->first-class m Class,
193193
std.findall (exported-op m P O) OPS,
194194
std.map OPS (c\out\ sigma p\ c = exported-op m p out) r) OPLL,
195195
std.flatten OPLL Operations,
@@ -207,7 +207,7 @@ main-structure S Class Structure MLwP :-
207207
PpClass = box (v 4) [
208208
str "HB: ", {pp-module Class}, str " is a factory for the following mixins:",
209209
{bulletize ML (m\r\ sigma tmp\
210-
if (mixin-first-class m Class)
210+
if (mixin->first-class m Class)
211211
(pp-module m tmp, r = glue [tmp, str " (* new, not from inheritance *)"])
212212
(pp-module m r))}],
213213
PpSubClasses = box (v 4) [
@@ -225,10 +225,10 @@ main-structure S Class Structure MLwP :-
225225
print-docstring Structure,
226226
coq.say.
227227

228-
func main-factory-constructor string, inductive, gref, gref.
229-
main-factory-constructor S F PhBuild Build :-
228+
func main-factory->constructor string, inductive, gref, gref.
229+
main-factory->constructor S F PhBuild Build :-
230230
% fetch
231-
std.once(gref-deps Build DMLwP),
231+
gref->deps Build DMLwP,
232232
list-w-params_list DMLwP DML,
233233
factory-provides (indt F) PMLwP,
234234
list-w-params_list PMLwP PML,
@@ -302,7 +302,7 @@ main-factory S Factory :-
302302
% fetch
303303
coq.env.projections Factory Ps,
304304
std.map-filter Ps (x\r\ x = some r) Fields,
305-
std.once (gref-deps (indt Factory) DMLwP),
305+
gref->deps (indt Factory) DMLwP,
306306
list-w-params_list DMLwP DML,
307307
factory-provides (indt Factory) PMLwP,
308308
list-w-params_list PMLwP PML,

HB/builders.elpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ postulate-factories ModName IDF CDecl :-
143143
context.declare.params-key FLwP ParamsSection FKey FLwA,
144144
std.assert! (FLwA = [triple GRF _ _])
145145
"HB: cannot declare builders for more than one factory at a time",
146-
std.once(gref-deps GRF DepswPRaw),
146+
gref->deps GRF DepswPRaw,
147147
context.declare.mixins FKey ParamsSection DepswPRaw _ _ _,
148148
std.map ParamsSection triple_2 FParams,
149149
postulate-factory-abbrev FKey FParams IDF GRF TheFactory,

HB/common/database.elpi

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ sub-class? (class C1 _ ML1P) (class C2 _ ML2P) :-
8181
func factory-provides factoryname -> mixins.
8282
factory-provides FactoryAlias MLwP :- std.do! [
8383
std.assert-ok! (factory-alias->gref FactoryAlias Factory) "HB",
84-
gref-deps Factory RMLwP,
84+
gref->deps Factory RMLwP,
8585
w-params.map RMLwP (factory-provides.base Factory) MLwP
8686
].
8787

@@ -112,7 +112,7 @@ extract-conclusion-params TheType (prod _ S T) R :- !,
112112
@pi-decl _ S x\ extract-conclusion-params TheType (T x) R.
113113
extract-conclusion-params TheType (app [global GR|Args]) R :- !, std.do! [
114114
std.assert-ok! (factory-alias->gref GR Factory) "HB",
115-
factory-nparams Factory NP,
115+
factory->nparams Factory NP,
116116
std.map Args (copy-pack-holes TheType TheType) NewArgs,
117117
std.take NP NewArgs R].
118118
extract-conclusion-params TheType T R :- whd1 T T1, !, extract-conclusion-params TheType T1 R.
@@ -165,7 +165,7 @@ undup-cs-patterns L R :- std.do! [
165165
pred toposort-mixins i:list (w-args mixinname), o:list (w-args mixinname).
166166
toposort-mixins In Out :- std.do! [
167167
std.map In triple_1 ML,
168-
std.map ML (m\r\sigma D D1\ gref-deps m D1, list-w-params_list D1 D, std.map D (d\r\r = pr d m) r) ES2,
168+
std.map ML (m\r\sigma D D1\ gref->deps m D1, list-w-params_list D1 D, std.map D (d\r\r = pr d m) r) ES2,
169169
std.flatten ES2 ES,
170170
toposort-proj triple_1 ES In Out,
171171
].
@@ -231,14 +231,14 @@ pred findall-mixin-src i:term, o:list mixinname.
231231
findall-mixin-src T ML :-
232232
std.map {std.findall (mixin-src T M_ V_)} mixin-src_mixin ML.
233233

234-
func findall-factory-constructor -> list prop.
235-
findall-factory-constructor L :-
236-
std.map {std.findall (findall-factory-constructor.aux _)} findall-factory-constructor.make L.
237-
pred findall-factory-constructor.aux o:prop.
238-
findall-factory-constructor.aux (factory-constructor F C) :-
239-
is-factory F, factory-constructor F C.
240-
func findall-factory-constructor.make prop -> prop.
241-
findall-factory-constructor.make (findall-factory-constructor.aux P) P.
234+
func findall-factory->constructor -> list prop.
235+
findall-factory->constructor L :-
236+
std.map {std.findall (findall-factory->constructor.aux _)} findall-factory->constructor.make L.
237+
pred findall-factory->constructor.aux o:prop.
238+
findall-factory->constructor.aux (factory->constructor F C) :-
239+
is-factory F, factory->constructor F C.
240+
func findall-factory->constructor.make prop -> prop.
241+
findall-factory->constructor.make (findall-factory->constructor.aux P) P.
242242

243243
pred findall-local-canonical o:list constant.
244244
findall-local-canonical CL :-
@@ -441,14 +441,14 @@ has-CS-instance? TyTerm (indt Struct) :- std.do! [
441441
pred structure-nparams i:structure, o:int.
442442
structure-nparams Structure NParams :-
443443
class-def (class Class Structure _),
444-
factory-nparams Class NParams.
444+
factory->nparams Class NParams.
445445

446446
pred factory? i:term, o:w-args factoryname.
447447
factory? S (triple F Params T) :-
448448
not (var S), !,
449449
safe-dest-app S (global GR) Args,
450450
factory-alias->gref GR F ok,
451-
factory-nparams F NP, !,
451+
factory->nparams F NP, !,
452452
std.split-at NP Args Params [T|_].
453453

454454
% [find-max-classes Mixins Classes] states that Classes is a list of classes
@@ -460,7 +460,7 @@ factory? S (triple F Params T) :-
460460
pred find-max-classes i:list mixinname, o:list classname.
461461
find-max-classes [] [].
462462
find-max-classes [M|Mixins] [C|Classes] :-
463-
mixin-first-class M C,
463+
mixin->first-class M C,
464464
std.do! [
465465
class-def (class C _ MLwP),
466466
list-w-params_list MLwP ML,

HB/common/phant-abbreviation.elpi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ add-abbreviation N (private.phant-term AL T1) C Abbrev :- std.do! [
3737
% and before the source keu to replace the target key by a user chosen one.
3838
pred of-gref i:bool, i:gref, i:list mixinname, o:phant-term.
3939
of-gref WithCopy GRF RealMixinArgs PhBody:- !, std.do! [
40-
std.assert! (gref-deps GRF MLwP) "mk-phant-term: unknown gref",
40+
std.assert! (gref->deps GRF MLwP) "mk-phant-term: unknown gref",
4141
std.assert! (coq.env.typeof GRF FTy) "mk-phant-term: F illtyped",
4242
coq.mk-eta (-1) FTy (global GRF) EtaF,
4343
% toposort-mixins ML MLSorted,
@@ -258,7 +258,7 @@ mk-phant-term.mixins Target Src CN PF Params N Ty MLwA Out :- std.do! [
258258

259259
mk-phant-term.mixins.aux T Params C CN PF X :- std.do![
260260
get-constructor CN KC,
261-
synthesis.infer-all-gref-deps Params T KC KCM,
261+
synthesis.infer-all-gref->deps Params T KC KCM,
262262
fun-unify none KCM C PF X,
263263
].
264264

HB/common/stdpp.elpi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,6 @@ term->cs-pattern T (cs-gref GR) :- coq.term->gref T GR.
285285
term->cs-pattern T _ :- coq.error T "HB database: is not a valid canonical key".
286286

287287

288-
% this one is in utils, maybe cs-pattern->name is not stdpp material
289-
pred gref->modname-label i:gref, i:int, i:string, o:string.
290-
291-
pred cs-pattern->name i:cs-pattern, o:string.
292-
cs-pattern->name cs-prod "prod".
293-
cs-pattern->name (cs-sort _) "sort".
294-
cs-pattern->name cs-default "default".
295-
cs-pattern->name (cs-gref GR) Name :- gref->modname-label GR 1 "_" Name.
296-
297288
% ---------------------------------------------------------------------
298289
% kit for closing a term by abstracting evars with lambdas
299290
% we use constraints to attach to holes a number

HB/common/synthesis.elpi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ infer-all-these-mixin-args Ps T ML F SFX :- std.do! [
2323
private.instantiate-all-these-mixin-args FT T ML SFX,
2424
].
2525

26-
% [infer-all-gref-deps Ps T GR X] fills in all the arguments of GR
27-
% which are misxins in gref-deps GR, other arguments are abstracted
28-
pred infer-all-gref-deps i:list term, i:term, i:gref, o:term.
29-
infer-all-gref-deps Ps T GR X :- std.do! [
30-
std.assert! (gref-deps GR MLwP) "BUG: gref-deps should never fail",
26+
% [infer-all-gref->deps Ps T GR X] fills in all the arguments of GR
27+
% which are misxins in gref->deps GR, other arguments are abstracted
28+
pred infer-all-gref->deps i:list term, i:term, i:gref, o:term.
29+
infer-all-gref->deps Ps T GR X :- std.do! [
30+
std.assert! (gref->deps GR MLwP) "BUG: gref->deps should never fail",
3131
list-w-params_list MLwP ML,
3232
coq.env.typeof GR Ty,
3333
coq.mk-eta (-1) Ty (global GR) EtaF,
@@ -52,7 +52,7 @@ infer-holes-depending-on-pack T (app [global GR | Args]) S :-
5252
((coq.gref->id GR GRS, rex.match "phant.*" GRS /*TODO: phant-clone? GR N*/);
5353
pack? GR _),
5454
coq.env.typeof GR Ty, class-of-phant Ty KC SC C,
55-
factory-nparams C N,
55+
factory->nparams C N,
5656
std.take N Args Params, !,
5757
std.do! [
5858
infer-all-args-let Params T KC ClassInstance ok,
@@ -134,7 +134,7 @@ pred under-mixins.then i:list (w-args mixinname),
134134
i:(A -> prop), o:A.
135135
under-mixins.then [] _ Pred Body :- !, Pred Body.
136136
under-mixins.then [triple M Args T|ML] MkFun Pred Out :- std.do! [
137-
infer-all-gref-deps Args T M MTy,
137+
infer-all-gref->deps Args T M MTy,
138138
(@pi-decl `m` MTy m\ mixin-src T M m =>
139139
under-mixins.then ML MkFun Pred (Body m)),
140140
MkFun `m` MTy Body Out,
@@ -235,7 +235,7 @@ pred builder->term i:list term, i:term, i:factoryname, i:mixinname, o:term.
235235
builder->term Ps T Src Tgt B :- !, std.do! [
236236
from Src Tgt FGR,
237237
F = global FGR,
238-
gref-deps Src MLwP,
238+
gref->deps Src MLwP,
239239
list-w-params_list MLwP ML,
240240
infer-all-these-mixin-args Ps T ML F B,
241241
].

HB/common/utils.elpi

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ nice-gref->string X Mod :-
6969
nice-gref->string X S :-
7070
coq.term->string (global X) S.
7171

72-
pred gref->modname i:gref, i:int, i:string, o:string.
72+
func gref->modname gref, int, string -> string.
7373
gref->modname GR NComp Sep ModName :-
7474
coq.gref->path GR Path,
7575
std.rev Path Mods,
7676
std.length Path Len,
7777
if (Len >= NComp) true (coq.error "Not enough enclosing modules for" {coq.gref->string GR}),
7878
std.take NComp Mods L,
7979
std.string.concat Sep {std.rev L} ModName.
80-
pred gref->modname-label i:gref, i:int, i:string, o:string.
80+
func gref->modname-label gref, int, string -> string.
8181
gref->modname-label GR NComp Sep ModName :-
8282
coq.gref->path GR Path,
8383
std.rev Path PathRev,
@@ -86,15 +86,22 @@ gref->modname-label GR NComp Sep ModName :-
8686
std.take N PathRev L,
8787
std.string.concat Sep {std.rev [{coq.gref->id GR}|L]} ModName.
8888

89+
pred cs-pattern->name i:cs-pattern, o:string.
90+
cs-pattern->name cs-prod "prod".
91+
cs-pattern->name (cs-sort _) "sort".
92+
cs-pattern->name cs-default "default".
93+
cs-pattern->name (cs-gref GR) Name :- gref->modname-label GR 1 "_" Name.
94+
95+
8996
func string->modpath string -> modpath.
9097
string->modpath S MP :-
9198
std.filter {coq.locate-all S} (l\l = loc-modpath _) L,
9299
L = [loc-modpath MP].
93100

94-
pred gref->modname_short1 i:modpath, i:string, i:list string, o:string.
95-
gref->modname_short1 _ S [] S.
96-
gref->modname_short1 MP "" [X|L] L' :- gref->modname_short1 MP X L L'.
97-
gref->modname_short1 MP S _ S :- string->modpath S MP.
101+
func gref->modname_short1 modpath, string, list string -> string.
102+
gref->modname_short1 _ S [] S :- !.
103+
gref->modname_short1 MP "" [X|L] L' :- !, gref->modname_short1 MP X L L'.
104+
gref->modname_short1 MP S _ S :- !, string->modpath S MP.
98105
gref->modname_short1 MP S [X|L] S' :-
99106
gref->modname_short1 MP {std.string.concat "." [X,S]} L S'.
100107

HB/context.elpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ postulate-mixin TheType (triple M Ps T) (triple CL MSL MLwP) (triple OutCL [MC|M
6363

6464
if-verbose (coq.say "HB: postulate" Name "on" {coq.term->string T}),
6565

66-
synthesis.infer-all-gref-deps Ps T M TySkel,
66+
synthesis.infer-all-gref->deps Ps T M TySkel,
6767
% was synthesis.infer-all-mixin-args Ps T M TySkel,
6868
% if-verbose (coq.say "HB: postulate-mixin checking" TySkel),
6969
% std.assert-ok! (coq.typecheck Ty _) "postulate-mixin: Ty illtyped",

HB/factory.elpi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ cdecl->w-mixins.mixins (context-item ID _ TySkel none Rest) Out :- !,
193193
% The identity builder
194194
pred declare-id-builder i:factoryname, o:prop.
195195
declare-id-builder GR (from GR GR (const C)) :- std.do! [
196-
gref-deps GR GRD,
196+
gref->deps GR GRD,
197197
synthesis.mixins-w-params.fun GRD (declare-id-builder.aux GR) IDBodySkel,
198198
std.assert-ok! (coq.elaborate-skeleton IDBodySkel IDType IDBody) "identity builder illtyped",
199199
log.coq.env.add-const-noimplicits "identity_builder" IDBody IDType @transparent! C,
200200
].
201201
declare-id-builder.aux GR Params TheType (fun `x` Ty x\x) :-
202-
synthesis.infer-all-gref-deps Params TheType GR Ty.
202+
synthesis.infer-all-gref->deps Params TheType GR Ty.
203203

204204
% [mk-factory-abbrev Str GR CL FactAbbrev]
205205
% creates an abbreviation for GR names Str and creates a phant-abbrev clause in CL.
@@ -275,7 +275,7 @@ declare-mixin-or-factory MixinSrcClauses SectionCanonicalInstance
275275
factories-provide GRFSwP MLwP,
276276
w-params.nparams MLwP NParams,
277277
build-deps-for-projections R MLwP GRDepsClausesProjs,
278-
GRDepsClauses = [gref-deps (indt R) MLwP, gref-deps (indc K) MLwP|GRDepsClausesProjs],
278+
GRDepsClauses = [gref->deps (indt R) MLwP, gref->deps (indc K) MLwP|GRDepsClausesProjs],
279279

280280
% GRDepsClauses => mk-factory-sort MLwP (indt R) _ FactorySortCoe,
281281
% FactorySortCoe = coercion GRFSort _ _ _,
@@ -300,11 +300,11 @@ declare-mixin-or-factory MixinSrcClauses SectionCanonicalInstance
300300
log.coq.env.begin-module "Exports" none,
301301
std.flatten [Clauses, GRDepsClauses, [
302302
is-factory (indt R),
303-
factory-constructor (indt R) GRK,
304-
factory-nparams (indt R) NParams,
303+
factory->constructor (indt R) GRK,
304+
factory->nparams (indt R) NParams,
305305
factory-builder-nparams BuildConst NParams,
306306
phant-abbrev GRK (const BuildConst) BuildAbbrev,
307-
% gref-deps GRFSort MLwP,
307+
% gref->deps GRFSort MLwP,
308308
% factory-sort FactorySortCoe,
309309
]] NewClauses,
310310
acc-clauses current NewClauses,
@@ -339,9 +339,9 @@ declare-factory-alias MixinSrcClauses SectionCanonicalInstance
339339

340340
std.assert! (safe-dest-app Ty1 (global PhF) _Args) "Argument must be a factory",
341341
std.assert-ok! (factory-alias->gref PhF F) "HB",
342-
std.assert! (factory-constructor F FK) "BUG: Factory constructor missing",
342+
std.assert! (factory->constructor F FK) "BUG: Factory constructor missing",
343343

344-
MixinSrcClauses => synthesis.infer-all-gref-deps TheParams TheType FK MFK,
344+
MixinSrcClauses => synthesis.infer-all-gref->deps TheParams TheType FK MFK,
345345
std.assert-ok! (coq.typecheck MFK MFKTy) "BUG: typecking of former factory constructor failed",
346346
(pi Args\ copy (app[global F|Args]) (app[global (const C)|Section])) => copy MFKTy MFKTyC,
347347

@@ -355,14 +355,14 @@ declare-factory-alias MixinSrcClauses SectionCanonicalInstance
355355
@global! => log.coq.arguments.set-implicit GRK [[]],
356356

357357
factories-provide GRFSwP MLwP,
358-
GRDepsClauses = [gref-deps (const C) MLwP, gref-deps (const CK) MLwP],
358+
GRDepsClauses = [gref->deps (const C) MLwP, gref->deps (const CK) MLwP],
359359

360360
GRDepsClauses => phant.of-gref ff GRK [] PhGRK0,
361361

362362
% GRDepsClauses => mk-factory-sort MLwP (const C) _ FactorySortCoe,
363363
% FactorySortCoe = coercion GRFSort _ _ _,
364364

365-
if (mixin-first-class F _) (PhGRK = PhGRK0)
365+
if (mixin->first-class F _) (PhGRK = PhGRK0)
366366
(phant.append-fun-unify PhGRK0 PhGRK),
367367
GRDepsClauses => phant.add-abbreviation "Build" PhGRK BuildConst _,
368368

@@ -375,10 +375,10 @@ declare-factory-alias MixinSrcClauses SectionCanonicalInstance
375375
w-params.nparams MLwP NParams,
376376
std.flatten [ Clauses, GRDepsClauses,
377377
[ is-factory (const C),
378-
factory-nparams (const C) NParams,
379-
factory-constructor (const C) GRK,
378+
factory->nparams (const C) NParams,
379+
factory->constructor (const C) GRK,
380380
factory-builder-nparams BuildConst NParams,
381-
% gref-deps GRFSort MLwP,
381+
% gref->deps GRFSort MLwP,
382382
% factory-sort FactorySortCoe
383383
]
384384
] NewClauses,
@@ -403,7 +403,7 @@ pred build-deps-for-projections i:inductive, i:mixins, o:list prop.
403403
build-deps-for-projections R MLwP CL :- std.do! [
404404
compat.map-filter {coq.env.projections R} (x\y\x = some y) MixinOps,
405405
list-w-params.rcons MLwP (pl\t\r\ r = triple (indt R) pl t) MLRwP,
406-
std.map MixinOps (gr\r\ r = gref-deps (const gr) MLRwP) CL,
406+
std.map MixinOps (gr\r\ r = gref->deps (const gr) MLRwP) CL,
407407
].
408408

409409
% Section handling in Coq is smart, in the sense it it only abstracts over
@@ -433,7 +433,7 @@ mk-factory-sort MLwP GR (const FactorySortCst) Coe :-
433433
synthesis.infer-coercion-tgt MLwP CoeClass,
434434
Coe = coercion (const FactorySortCst) MLwPLength GR CoeClass.
435435
pred mk-factory-sort.term i:gref, i:list term, i:term, o:term.
436-
mk-factory-sort.term GR P T (fun `_` Ty _\ T) :- synthesis.infer-all-gref-deps P T GR Ty.
436+
mk-factory-sort.term GR P T (fun `_` Ty _\ T) :- synthesis.infer-all-gref->deps P T GR Ty.
437437

438438

439439

0 commit comments

Comments
 (0)