janestreet / ppx_sexp_conv

Generation of S-expression conversion functions from type definitions
MIT License
88 stars 17 forks source link

`Sexpable` and Polymorphic variants #19

Closed SaswatPadhi closed 6 years ago

SaswatPadhi commented 6 years ago

I have a Sexpable module containing a polymorphic variant type. The signature I define looks like:

module type I =
  sig
    type t = [ `Foo ]

    include Base.Sexpable.S with type t := t
  end

And the implementation is:

module T : I =
  struct
    type t = [ `Foo ] [@@deriving sexp]
  end

But Sexpable does not expose __t_of_sexp__. So, when I try to use T in another module, like:

module M = 
  struct
    type tt = T.t [@@deriving sexp_poly]
    type t = [ tt | `Bar ] [@@deriving sexp]
  end

This fails because it cannot find __t_of_sexp__. Currently, I am manually exporting __t_of_sexp__ in my signature I, but it would be nice not to have to mess with the signature.

SaswatPadhi commented 6 years ago

Also reported it at janestreet/base#38. Please close this one if it's not relevant to this repo.

Thanks.

ghost commented 6 years ago

Why not use [@@deriving sexp] in the signature?

ghost commented 6 years ago

I just saw that the issue was resolved in the other ticket