ocaml-json: extract Codec and Error modules from json.ml
json.ml had grown to include the full Repr GADT representation (363
lines of combinator plumbing), the JSON-specific Error module (90 lines
wrapping Loc.Error with typed error kinds), plus the public facade -- a
2225-line monolith where the internal representation and the friendly
API were tangled together.
Move each into its own pair of files:
- lib/codec.ml{,i}: the codec GADT that the combinators walk, formerly
the internal [module Repr]. Renamed to [Codec] now that it lives in
a file of its own; the previous [module Repr = Codec] alias in
json.mli is removed. External users access it as [Json.Codec].
- lib/error.ml{,i}: the Sort_mismatch / Kinded_sort_mismatch extensible
kinds, their printer registration, and the message helpers
(kinded_sort, missing_mems, unexpected_mems, unexpected_case_tag,
integer_range, ...). Both json.ml and codec.ml now depend on it
directly, breaking the previous circular structure where codec-level
code reached into json.ml's Error module.
json.ml shrinks from 2225 to ~1525 lines and no longer mixes the
low-level GADT and the user-facing API. The public surface is
unchanged: Json.Codec keeps the same members the old Json.Repr
exposed, and [type 'a codec = 'a Codec.t] now threads through so
subpackages (brr, bytesrw) can call Json.Codec functions without
type-equality gymnastics.
Subpackage updates are purely mechanical renames: [Json.Repr] ->
[Json.Codec], [open Json.Repr] -> [open Json.Codec], and drop the
[Json.Codec.of_t] / [Json.Codec.unsafe_to_t] identity wrappers that
became trivial once [codec] is a manifest alias for [Codec.t].