I am not very familiar with Ocaml, but I believe that
let rec hoistfree : 'b.('bt -> 'bt) -> 'am -> 'am =
analyzed as
let rec hoistfree : 'b. ( ('bt -> 'bt) -> 'am -> 'am ) =
instead
let rec hoistfree : ('b. ('bt -> 'bt)) -> 'am -> 'am =
The former is the main polymorphic type, the latter is the rank2 type, which requires more support from the type system than the Hindley-Milner.
IIRC, to achieve the latter, you need to determine the data type of the custom wrapper. For instance:
type poly = { polyf: 'a . 'a -> 'a } ;; let foo (x: poly): int = x.polyf 4;; let bar: poly = { polyf = fun x -> x } ;; let _ = print_string ("hello " ^ string_of_int (foo bar));;
chi source share