janestreet / ppx_sexp_conv

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

Suggestion: [@sexp.unboxed] #36

Closed hackwaly closed 2 years ago

hackwaly commented 2 years ago
type 'a p = 'a * bool
[@@deriving sexp]

type t = 
  | A of int p [@sexp.unboxed] (* Here I want "(A 1 true)", not "(A (1 true))" *)
[@@deriving sexp]
ceastlund commented 2 years ago

The issue here is that ppx_sexp_conv has no way to statically guarantee that p produces a list sexp. So you could end up with sexps all defined using [@@deriving sexp] which are nevertheless incompatible, and would raise at runtime. You could certainly write this serialization manually, but I don't think we want to add it as a built-in given the limitations.