ppx_deriving_yojson
ppx_deriving_yojson copied to clipboard
Handling of Map, Set, ...
Do you plan to handle types generated with Map.Make, Set.Make and so on, for example using something like
module Key = struct type t = int let compare = compare end
module Int_map = Map.Make(Key)[@@deriving yojson]
The attribute on a module could mean "derive for all types in the module". I don't know if it's easy, since the Map.S.t is abstract. But may be you could use the Map functions to list elements to create the json structure and re-create the map when reading the json structure.
It might be quite ad-hoc, but useful :)
If Key.t
implements the deriving yojson interface, this can be made possible. But first I think I'll need to handle regular, non-functor versions of Map and Hashtbl...
FYI: it's not the sort of automatic derivation that is envisaged here, but a workaround is now available on master via the @to_yojson
and @of_yojson
attributes (analogous to the show's @printer
attribute).