janestreet / bin_prot

Binary protocol generator
MIT License
73 stars 21 forks source link

[migration] Bin_prot v0.9.0 breaks hand-written bin_protters #14

Closed ghost closed 7 years ago

ghost commented 7 years ago

Bin_prot v0.9.0 adds bin_prot shapes, more details in shape/README.md. As a result, [@@deriving bin_prot] generates an additional function: bin_shape_<type>.

Code manually defining bin_prot functions is likely to break since this new function needs to be implemented. In most cases, this code can be replaced by the use of Bin_prot.Utils.Make_binable:

include Bin_prot.Utils.Make_binable
  (struct
     module Binable = <module with a type t that is bin_prottable>
     type t = <some OCaml type>
     let to_binable = <convert from t to Binable.t>
     let of_binable = <convert from Binable.t to t>
   end)

Using this functor will guarantee compability with both Bin_prot < v0.9.0 and Bin_prot v0.9.0.