janestreet / ppx_yojson_conv

[@@deriving] plugin to generate Yojson conversion functions
MIT License
58 stars 8 forks source link

Uninterpreted extension 'to_yojson'. #9

Open anentropic opened 3 years ago

anentropic commented 3 years ago

I'm trying to work out how to define my own to/from functions for some types that can't be derived automatically

I'm getting this error:

57 |     |> [%to_yojson: (string * Version.t) list]
              ^^^^^^^^^
Error: Uninterpreted extension 'to_yojson'.

I have (preprocess (pps ppx_yojson_conv)) and (libraries yojson) in my dune file

Is something else needed?

Also the readme seems to suggest that Hashtbl can be derived https://github.com/janestreet/ppx_yojson_conv#hash-tables

but:

module X = struct
  type t = (string, string) Hashtbl.t [@@deriving yojson]
end

gives: Unbound value Hashtbl.t_of_yojson

anentropic commented 3 years ago

the former seems to need (libraries ppx_deriving_yojson.runtime)?

smorimoto commented 3 years ago

Is there any update on this? I don't have enough time to take a deep look, but I stuck.

hhugo commented 3 years ago

It's not to_yojson. It should be [%yojson_of: ...]

anentropic commented 3 years ago

🤦‍♂️ thanks