Original bug ID: 6908 Reporter:@yallop Status: closed (set by @damiendoligez on 2015-07-20T13:15:02Z) Resolution: fixed Priority: normal Severity: minor Version: 4.02.2 Target version: 4.02.3+dev Fixed in version: 4.02.3+dev Category: ~DO NOT USE (was: OCaml general) Related to:#5958 Monitored by:@gasche@diml@hcarty
PR5958 changed the behaviour of #install_printer to make it possible to install printers for parameterised types. Unfortunately the change has broken some existing code for printing GADTs.
For example, if I have the following GADT definition
type (_, _) eql = Refl : ('a, 'a) eql
then the following printer works with #install_printer in 4.02.1, but is rejected in 4.02.2:
let format_eql : 'a 'b. Format.formatter -> ('a, 'b) eql -> unit =
fun fmt _ -> Format.pp_print_string fmt "reflexivity"
and the following printer works with #install_printer in 4.02.2 but is rejected in 4.02.1:
let format_eql : 'a 'b.
(Format.formatter -> 'a -> unit) ->
(Format.formatter -> 'b -> unit) ->
Format.formatter -> ('a, 'b) eql -> unit =
fun _ _ fmt _ -> Format.pp_print_string fmt "reflexivity";;
This is a problem in practice. For example, top-level printing no longer works in ctypes, which installs a number of printers of the first form:
I see no better solution than making the directive code more clever to detect types that (1) have type parameters but (2) do not expect printers for those parameters, and use the old behavior on those.
Maybe we could generalize this to accept that only a subset of the parameters expect printers (synthesizing printers does not make sense for phantom or even contravariant parameters). But a first goal should be to have a safe patch that solve ctypes immediate problem.