ott-lang / ott

The Ott tool for writing definitions of programming languages and calculi
Other
346 stars 44 forks source link

Ott support for JSON? #74

Open martinberger opened 3 years ago

martinberger commented 3 years ago

JSON has emerged as a standard format for data types serialisation, and most programming languages now have strong JSON support. For example Ocaml can auto-generate JSON pretty-printers and parsers for data types using yojson or adt. Both tools require compile-time meta-programming (e.g. in the form of @@deriving) for auto-generation of suitable pretty-printers and parsers.

How hard would it be to add support for automatic generation of support for JSON to OCaml types? Given that Ott has full control over the output, I imagine that it could be straightforward, with the possible exception of cases where the autogenerated code needs to be overridden with existing pretty-printers or parsers. (I'm asking because I want to JSON-ify Jib (the Sail IR) and I'm struggling to do this in a principled way. A similar question could be asked about Lem, but Jib is specified in Ott.)

PeterSewell commented 3 years ago

Mark Wassell added some support for JSON a few months back; I don't know whether it can already handle the Jib definition. https://github.com/ott-lang/ott/commit/c35957cb8c990ee3cbf852773381060de5ee1c7a

Peter

On Sat, 30 Jan 2021 at 14:55, Martin Berger notifications@github.com wrote:

JSON has emerged as a standard format for data types serialisation, and most programming languages now have strong JSON support. For example Ocaml can auto-generate JSON pretty-printers and parsers for data types using yojson or adt. Both tools require compile-time meta-programming (e.g. in the form of @@deriving) for auto-generation of suitable pretty-printers and parsers.

How hard would it be to add support for automatic generation of support for JSON to OCaml types? Given that Ott has full control over the output, I imagine that it could be straightforward, with the possible exception of cases where the autogenerated code needs to be overridden with existing pretty-printers or parsers. (I'm asking because I want to JSON-ify Jib (the Sail IR) and I'm struggling to do this in a principled way.)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ott-lang/ott/issues/74, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFMZZXZ2XY75O3OQHJZMH3S4QMVTANCNFSM4W2MARCA .