Skip to content

Commit 7356cf6

Browse files
committed
more doc
1 parent 3ab3e9c commit 7356cf6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

apps/derive/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,30 @@ Elpi Typecheck derive.
565565
```
566566

567567
So when the user `Import`s `better_std` he gets a fully loaded `derive`.
568+
569+
The code of the derivation must be put in a namespace. So `myder.elpi` should
570+
look like so
571+
572+
```elpi
573+
namespace derive.myder {
574+
575+
pred main i:gref, i:string, o:list prop.
576+
main GR Prefix Clauses :- std.do! [
577+
... % synthesize Body and Type
578+
Name is Prefix ^ "myconcept",
579+
coq.ensure-fresh-global-id Name FName,
580+
coq.env.add-const FName Body Type _ C,
581+
Clauses = [myder-done GR, myder GR (const C)],
582+
std.forall Clauses (x\
583+
coq.elpi.accumulate _ "derive.myder.db" (clause _ _ x)
584+
),
585+
].
586+
587+
}
588+
```
589+
590+
It is important that all clauses added to the database are also returned
591+
(see the last argument of `main`). Derive runs all derivations at once
592+
and databases are updated only when the program ends. So derive will
593+
assume, with `=>`, the clauses generated by one derivation before running the
594+
nest one.

0 commit comments

Comments
 (0)