ocaml-ppx / ppx_deriving_yojson

A Yojson codec generator for OCaml.
MIT License
157 stars 46 forks source link

Help on recursive types #120

Open Lesenr1 opened 4 years ago

Lesenr1 commented 4 years ago

Hi! I have a bunch of recursive types, one of which is using the Map fonctor. I tried to follow the example and wrote this:

module TMap = Map.Make( struct type t = string let compare = compare end)
type 'a tmap = 'a TMap.t

type mytmap = t_content tmap [@to_yojson (fun m -> TMap.bindings m |> [%to_yojson: (string * t_content) list])]
and t_content = {
  t1 : t1;
  t2 : t2;
}
and t1 = string
and t2 =
  | Foo of t2
  | Bar of mytmap
[@@deriving yojson]

When compiling, OCaml gives me Error: Uninterpreted extension 'to_yojson'.