Skip to content

Commit 6bfdad6

Browse files
authored
Clarify README for Rocq-Elpi JSON plugin
Updated README to clarify installation and usage instructions for the Rocq-Elpi JSON plugin.
1 parent d46078f commit 6bfdad6

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

apps/json/README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1-
Minimalistic binding to Yojson
2-
==============================
1+
Binding to Yojson
2+
=================
33

44
This 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

1010
Then you can access the APIs in [doc/json.elpi](doc/json.elpi) this way:
1111

1212
```coq
1313
From elpi Require Import elpi json.
1414
15+
(* Data you want to read from disk *)
1516
From yourproject Extra Dependency "data.json" as data.
1617
1718
1819
Elpi Command read_json.
19-
Elpi Accumulate Plugin "json.elpi".
20+
Elpi Accumulate Plugin "json.elpi". (* loads yojson bindings *)
2021
Elpi Accumulate lp:{{
2122
main [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

2937
Note: At the time of writing `rocq_makefile` fully supports this directive and

0 commit comments

Comments
 (0)