File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,15 @@ let reduce_compare l =
37
37
38
38
let wildcard_case ~typ int_cases =
39
39
let loc = ! Ast_helper. default_loc in
40
+ let to_int_fun = [% expr fun (x : [%t typ] ) -> [% e Exp. match_ [% expr x] int_cases]] in
41
+ (* Need explicit polymorphic type for pre-OCaml 4.11 compatibility,
42
+ but just using Ppx_deriving.strong_type_of_type doesn't work,
43
+ so adding explicit polymorphism using (type a) arguments instead.
44
+ See: https://github.com/ocaml-ppx/ppx_deriving/pull/260#issuecomment-1072995847. *)
45
+ let free_vars = Ppx_deriving. free_vars_in_core_type typ in
46
+ let poly_to_int_fun = List. fold_right Exp. newtype free_vars to_int_fun in
40
47
Exp. case [% pat? _] [% expr
41
- let to_int: [ % t typ] -> Ppx_deriving_runtime. int = [% e Exp. function_ int_cases ] in
48
+ let to_int = [% e poly_to_int_fun ] in
42
49
Ppx_deriving_runtime. compare (to_int lhs) (to_int rhs)]
43
50
44
51
let pattn side typs =
You can’t perform that action at this time.
0 commit comments