Skip to content

Commit

Permalink
Add derive.param2.register
Browse files Browse the repository at this point in the history
  • Loading branch information
proux01 committed Jan 29, 2025
1 parent f1f334f commit abf6d7c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/derive/elpi/param2.elpi
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ pred main i:gref, i:string, o:list prop.
main T _ Clauses :-
dispatch T "_R" Clauses.

pred main_register i:gref, i:gref.
main_register I R :-
GI = global I, GR = global R,
C1 = (param GI GI GR :- !),
coq.elpi.accumulate _ "derive.param2.db" (clause _ (before "param:fail") C1),
C2 = (paramR GI GI GR :- !),
coq.elpi.accumulate _ "derive.param2.db" (clause _ (before "paramR:fail") C2),
coq.elpi.accumulate _ "derive.param2.db" (clause _ _ (param-done I)).

}

/*
Expand Down
9 changes: 9 additions & 0 deletions apps/derive/tests/test_param2.v
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,12 @@ Definition size_seq (A : Type) : size_of (list A) := fun _ => 0.
Elpi derive.param2 size_of.

Elpi derive.param2 size_seq. (* Fixed by https://github.com/LPCIC/coq-elpi/pull/754 *)

Definition fa := 0.
Definition fb := fa.

Fail Elpi derive.param2 fb.

Definition fa_R := O_R.
Elpi derive.param2.register fa fa_R.
Elpi derive.param2 fb.
11 changes: 11 additions & 0 deletions apps/derive/theories/derive/param2.v
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ Elpi Accumulate lp:{{
usage :- coq.error "Usage: derive.param2 <object name>".
}}.

Elpi Command derive.param2.register.
Elpi Accumulate File param2.
Elpi Accumulate Db derive.param2.db.
Elpi Accumulate lp:{{
main [str I, str R] :- !, coq.locate I GRI, coq.locate R GRR,
derive.param2.main_register GRI GRR.
main _ :- usage.

usage :- coq.error "Usage: derive.param2.register <name> <name_R>".
}}.


(* hook into derive *)
Elpi Accumulate derive File param2.
Expand Down

0 comments on commit abf6d7c

Please sign in to comment.