support polymorphic ocaml.type
Closed this issue · 1 comments
ygrek commented
With #10 fixed, consider the following :
$ cat a.proto
type q 'a = [ 'a ] options "ocaml.type" = "'a list, f, g"
type iq = { i : q<int>; }
$ extprotc a.proto -o /dev/stdout
module Q =
struct type 'a q = 'a list;; let pp_q pp_a ppf x = Extprot.Pretty_print.pp_list pp_a ppf (g x);;
end;;
module Iq =
struct
type iq = { i : 'a list };;
let pp_iq =
Extprot.Pretty_print.pp_struct
[ ("Iq.i",
(Extprot.Pretty_print.pp_field (fun t -> t.i) (Q.pp_q Extprot.Pretty_print.pp_int))) ];;
end;;
type iq
is wrong, afaiu extprot doesn't substitute type variables in ocaml.type
- fair enough, but it seems an easy fix would be to generate type iq = { i : int q; }
ie going through left-hand type. Sorry if my understanding is too naive.
ygrek commented
Disregard, this obviously doesn't hold when ocaml.type is different from original type (which is 99% of non-trivial cases)