ppx_deriving_yojson
ppx_deriving_yojson copied to clipboard
cycle detection
trafficstars
Currently, cyclic values lead to a stack overflow. It would be nice to have some option (maybe just for debugging) to get some information where a cycle happened.
# type t = A of t | B [@@deriving to_yojson]
type t = A of t | B
val to_yojson : t -> Yojson.Safe.json = <fun>
# to_yojson B
- : Yojson.Safe.json = `List [`String "B"]
# let rec x = A x
val x : t = A <cycle>
# to_yojson x
Stack overflow during evaluation (looping recursion?).
Raised by primitive operation at file "//toplevel//", line 1, characters 0-42 Called from file "//toplevel//", line 1, characters 0-42