| 1 | Binding to Yojson |
| 2 | ================= |
| 3 | |
| 4 | This Rocq-Elpi plugin gives access to json files. |
| 5 | |
| 6 | ```bash |
| 7 | opam install rocq-elpi-json # pulls in yojson |
| 8 | ``` |
| 9 | |
| 10 | Then you can access the APIs in [doc/json.elpi](doc/json.elpi) this way: |
| 11 | |
| 12 | ```coq |
| 13 | From elpi Require Import elpi json. |
| 14 | |
| 15 | From elpi.json.tests Extra Dependency "test.json" as json_test_file. |
| 16 | |
| 17 | Elpi Command hello_json. |
| 18 | Elpi Accumulate Plugin "json.elpi". |
| 19 | Elpi Accumulate lp:{{ |
| 20 | main [str D] :- |
| 21 | std.assert-ok! (coq.extra-dep->json D J) "bad file", |
| 22 | coq.say "json AST:" J, |
| 23 | coq.json->string J S, |
| 24 | coq.say "pretty:" S, |
| 25 | coq.string->json S J', |
| 26 | coq.say "json AST:" J', |
| 27 | std.assert! (J = J') "this would be bad". |
| 28 | }}. |
| 29 | Elpi Export hello_json. |
| 30 | |
| 31 | hello_json "json_test_file". |
| 32 | ``` |
| 33 | |
| 34 | Note: At the time of writing `rocq_makefile` fully supports this directive and |
| 35 | considers `<file>` as a dependency of the `.v` file. Dune does not yet |
| 36 | support this. For a workaround see the [tests/](tests-plugin/) directory. |
| 37 |