Skip to content

Commit

Permalink
Use the new HOAS:holes option of coq-elpi
Browse files Browse the repository at this point in the history
  • Loading branch information
gares committed Jul 20, 2020
1 parent ef8c454 commit 12090fb
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions hb.elpi
Expand Up @@ -1690,7 +1690,10 @@ is-last-named-asset-param (asset-parameter _ _ _\ asset-alias _ _) :- !.

% main-declare-asset Asset AssetKind
pred main-declare-asset i:asset-decl, i:asset.
main-declare-asset Asset AssetKind :- std.do! [
main-declare-asset Asset AssetKind :-
% since we turn locally bound variables into global constrants the holes
% in the input term can go outside the pattern fragment, but we don't care
@HOAS:holes => std.do! [
name-of-asset-decl Asset Module,

if-verbose (coq.say "HB: start module and section" Module),
Expand Down Expand Up @@ -1729,24 +1732,15 @@ process-asset-unnamed-parameters (asset-parameter _ T Rest) FS Module TheType D
process-asset-unnamed-parameters (Rest Dummy) [triple F Ps TheType|FS] Module TheType D Params,
].

% (*) We did substitute bound variables by terms, we would end up outside the pattern fragment
% X x = (global(cont "foo")) X := _\ (global ...) 1 solution
% X x = x X := a\a 1 solution
% X x (global(cont "foo")) = (global(cont "foo")) X := _\a\a or X := _\_\ (global ...) 2 solution, bad

process-asset-unnamed-parameters (asset-alias _ Ty) GRFS Module TheType D Params :- std.do! [
std.assert! (D = asset-factory) "Mixins cannot be aliases",
% refresh implicit arguments, since many binders are now gone (*)
(pi X Y\ copy X Y :- var X, !) => copy Ty Ty1,
build-list-w-params Params TheType {std.rev GRFS} GRFSwParams,
declare-factory-alias Ty1 GRFSwParams Module TheType {std.map Params fst},
declare-factory-alias Ty GRFSwParams Module TheType {std.map Params fst},
].

process-asset-unnamed-parameters (asset-record _ Sort _ Fields) GRFS Module TheType D Params :- std.do! [
% refresh implicit arguments, since many binders are now gone
(pi X Y\ copy X Y :- var X, !) => (copy-fields Fields Fields0, copy Sort Sort1),
build-list-w-params Params TheType {std.rev GRFS} GRFSwParams,
declare-mixin-or-factory Sort1 Fields0 GRFSwParams Module TheType D {std.map Params fst},
declare-mixin-or-factory Sort Fields GRFSwParams Module TheType D {std.map Params fst},
].

pred declare-factory-alias i:term, i:list-w-params factoryname, i:id, i:term, i:list term.
Expand Down

0 comments on commit 12090fb

Please sign in to comment.