File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 1- Minimalistic binding to Yojson
2- ==============================
1+ Binding to Yojson
2+ =================
33
44This Rocq-Elpi plugin gives access to json files.
55
66``` bash
7- opam install rocq-elpi-json # pulls is yojson
7+ opam install rocq-elpi-json # pulls in yojson
88```
99
1010Then you can access the APIs in [ doc/json.elpi] ( doc/json.elpi ) this way:
1111
1212``` coq
1313From elpi Require Import elpi json.
1414
15+ (* Data you want to read from disk *)
1516From yourproject Extra Dependency "data.json" as data.
1617
1718
1819Elpi Command read_json.
19- Elpi Accumulate Plugin "json.elpi".
20+ Elpi Accumulate Plugin "json.elpi". (* loads yojson bindings *)
2021Elpi Accumulate lp:{{
2122main [str Dep] :-
22- std.assert-ok! (coq.extra-dep->json from_file Dep X) "json",
23- coq.say X
23+ std.assert-ok! (coq.extra-dep->json Dep X) "json",
24+ coq.say "json data:" X, % as an Elpi syntax tree
25+ coq.say "pretty printed:" {coq.json->string X},
26+ std.assert! (X =
27+ json.assoc [ % keys are sorted for us
28+ pr "first_name" (json.string "John"),
29+ pr "is_alive" (json.bool tt),
30+ pr "last_name" (json.string "Smith")])
31+ "not my data".
2432}}.
2533
26- Elpi read_json data.
34+ Elpi read_json data. (* data is the name of the Extra Dependency *)
2735```
2836
2937Note: At the time of writing ` rocq_makefile ` fully supports this directive and
You can’t perform that action at this time.
0 commit comments