Skip to content
Merged
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
15 changes: 11 additions & 4 deletions structures.v
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ hack-section-discharging B B1 :- current-mode (builder-from TheFactory _), !,
B1 = {{ let _ : lp:TheFactoryTy := lp:TheFactory in lp:B }}.
hack-section-discharging B B.

pred optimize-body i:term, o:term.
optimize-body (app[global (const C)| Args]) Red :- phant-abbrev _ (const C) _, !,
coq.env.const C (some B) _,
hd-beta B Args HD Stack,
unwind HD Stack Red.
optimize-body X X.

main [const-decl Name (some BodySkel) TyWPSkel] :- !, std.do! [
std.assert-ok! (coq.elaborate-arity-skeleton TyWPSkel _ TyWP) "Definition type illtyped",
coq.arity->term TyWP Ty,
Expand All @@ -354,10 +361,10 @@ main [const-decl Name (some BodySkel) TyWPSkel] :- !, std.do! [
factory-alias->gref FactoryAlias Factory,
std.assert! (factory-nparams Factory NParams) "Not a factory synthesized by HB",
hack-section-discharging SectionBody SectionBodyHack,
if (Name = "_")
(TheFactory = SectionBodyHack)
(hb-add-const Name SectionBodyHack _ @transparent! C,
TheFactory = (global (const C))),
optimize-body SectionBodyHack OptimizedBody,
if (Name = "_") (RealName is "HB_unnamed_factory_" ^ {std.any->string {new_int} }) (RealName = Name),
hb-add-const RealName OptimizedBody _ @transparent! C,
TheFactory = (global (const C)),
std.appendR {coq.mk-n-holes NParams} [TheType|_] Args,
with-attributes (main-declare-instance TheType TheFactory Clauses),

Expand Down