You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add OCaml-to-jsonlike serializers and jsonlike-to-YAML converter (#504)
## Summary
- Implements #502: atdml now generates `jsonlike_of_foo` and
`Foo.to_jsonlike` functions for every ATD type, enabling serialization
from OCaml values to `Atd_jsonlike.AST.t`
- Implements #503: atd-yamlx gains `to_yamlx_value : Atd_jsonlike.AST.t
-> YAMLx.value`, the reverse of the existing `of_yamlx_value`
- Adds `Pos.zero` and `Loc.zero` to atd-jsonlike for constructing nodes
programmatically without source location information
## Generated API (per ATD type `foo`)
```ocaml
val jsonlike_of_foo : foo -> Atd_jsonlike.AST.t
module Foo : sig
type nonrec t = foo
val of_jsonlike : Atd_jsonlike.AST.t -> t
val to_jsonlike : t -> Atd_jsonlike.AST.t
...
end
```
Generated nodes carry `Atd_jsonlike.Loc.zero` (no source location).
## Design notes
- Adapter support: module-based adapters with `M.restore` are extended
to call `M.restore_jsonlike` in the jsonlike writer path, mirroring how
`M.normalize_jsonlike` extends `M.normalize` for the reader
- The test for the `adapter` case now includes a `restore_jsonlike`
function in `My_adapter.ml`
- The `imports e2e` test's `Long.ml` now includes `jsonlike_of_tag`
alongside `tag_of_jsonlike`
- End-to-end tests verify the full writer round-trip: OCaml → jsonlike →
OCaml → yojson must match the direct OCaml → yojson path
## Test plan
- [x] `dune build` passes
- [x] `cd atdml && ./test` — all 47 tests pass (44 pass, 3 xfail)
- [x] `dune runtest atd-yamlx/` — all 5 tests pass (3 original + 2 new)
- [x] `dune runtest atd-jsonlike/` — passes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments