ahrefs / atd

Static types for JSON APIs
Other
316 stars 52 forks source link

Annotate generated code with types to disambiguate OCaml classic variants #331

Closed sebastiantoh closed 1 year ago

sebastiantoh commented 1 year ago

This PR adds type annotations to generated code, in order to disambiguate OCaml classic variants

The generated code produced from the example below fails to compile due to ambiguity

type ambiguous = [
   | Int of int
   | String of string
 ]
   <json adapter.ocaml="Json_adapters.Identity">
 <ocaml repr="classic">

 type ambiguous' = [
   | Int of int
   | String of string
 ]
   <json adapter.ocaml="Json_adapters.Identity">
 <ocaml repr="classic">

PR checklist

mjambon commented 1 year ago

This is very nice. Thank you!