diff options
author | Stephane Glondu <steph@glondu.net> | 2019-08-20 11:14:30 +0200 |
---|---|---|
committer | Stephane Glondu <steph@glondu.net> | 2019-08-20 11:14:30 +0200 |
commit | 5c3452d8a43e801580493edabb79538d854ff77a (patch) | |
tree | 9882cc06ad5b2e3d72a4b301816a5bb2ff7a83d3 /src_plugins | |
parent | d09b1bf50d413215c6b4c605e058a67539f49b80 (diff) |
New upstream version 4.3
Diffstat (limited to 'src_plugins')
-rw-r--r-- | src_plugins/dune | 151 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_create.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_enum.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_eq.cppo.ml | 2 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_eq.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_fold.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_iter.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_make.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_map.cppo.ml | 3 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_map.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_ord.cppo.ml | 4 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_ord.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_show.cppo.ml | 97 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_show.mllib | 1 | ||||
-rw-r--r-- | src_plugins/ppx_deriving_std.ml | 1 |
15 files changed, 207 insertions, 60 deletions
diff --git a/src_plugins/dune b/src_plugins/dune new file mode 100644 index 0000000..06085ea --- /dev/null +++ b/src_plugins/dune @@ -0,0 +1,151 @@ +(rule + (deps ppx_deriving_show.cppo.ml) + (targets ppx_deriving_show.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_show) + (public_name ppx_deriving.show) + (synopsis "[@@deriving show]") + (modules ppx_deriving_show) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(rule + (deps ppx_deriving_create.cppo.ml) + (targets ppx_deriving_create.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_create) + (public_name ppx_deriving.create) + (synopsis "[@@deriving create]") + (modules ppx_deriving_create) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(rule + (deps ppx_deriving_enum.cppo.ml) + (targets ppx_deriving_enum.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_enum) + (public_name ppx_deriving.enum) + (synopsis "[@@deriving enum]") + (modules ppx_deriving_enum) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(rule + (deps ppx_deriving_eq.cppo.ml) + (targets ppx_deriving_eq.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_eq) + (public_name ppx_deriving.eq) + (synopsis "[@@deriving eq]") + (modules ppx_deriving_eq) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(rule + (deps ppx_deriving_fold.cppo.ml) + (targets ppx_deriving_fold.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_fold) + (public_name ppx_deriving.fold) + (synopsis "[@@deriving fold]") + (modules ppx_deriving_fold) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(rule + (deps ppx_deriving_iter.cppo.ml) + (targets ppx_deriving_iter.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_iter) + (public_name ppx_deriving.iter) + (synopsis "[@@deriving iter]") + (modules ppx_deriving_iter) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(rule + (deps ppx_deriving_make.cppo.ml) + (targets ppx_deriving_make.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_make) + (public_name ppx_deriving.make) + (synopsis "[@@deriving make]") + (modules ppx_deriving_make) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(rule + (deps ppx_deriving_map.cppo.ml) + (targets ppx_deriving_map.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_map) + (public_name ppx_deriving.map) + (synopsis "[@@deriving map]") + (modules ppx_deriving_map) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(rule + (deps ppx_deriving_ord.cppo.ml) + (targets ppx_deriving_ord.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(library + (name ppx_deriving_ord) + (public_name ppx_deriving.ord) + (synopsis "[@@deriving ord]") + (modules ppx_deriving_ord) + (preprocess + (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file}))) + (libraries compiler-libs.common ppx_tools ppx_deriving.api) + (kind ppx_deriver)) + +(library + (name ppx_deriving_std) + (public_name ppx_deriving.std) + (synopsis "Meta-package for all built-in derivers") + (modules ppx_deriving_std) + (libraries + ppx_deriving_ord + ppx_deriving_map + ppx_deriving_iter + ppx_deriving_enum + ppx_deriving_show + ppx_deriving_eq + ppx_deriving_make + ppx_deriving_create + ppx_deriving_fold) + (kind ppx_deriver)) diff --git a/src_plugins/ppx_deriving_create.mllib b/src_plugins/ppx_deriving_create.mllib deleted file mode 100644 index 1b2681b..0000000 --- a/src_plugins/ppx_deriving_create.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_create diff --git a/src_plugins/ppx_deriving_enum.mllib b/src_plugins/ppx_deriving_enum.mllib deleted file mode 100644 index 06890cb..0000000 --- a/src_plugins/ppx_deriving_enum.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_enum diff --git a/src_plugins/ppx_deriving_eq.cppo.ml b/src_plugins/ppx_deriving_eq.cppo.ml index 41e505e..67efcb1 100644 --- a/src_plugins/ppx_deriving_eq.cppo.ml +++ b/src_plugins/ppx_deriving_eq.cppo.ml @@ -71,7 +71,7 @@ and expr_of_typ quoter typ = let builtin = not (attr_nobuiltin typ.ptyp_attributes) in begin match builtin, typ with | true, [%type: unit] -> - [%expr fun _ _ -> true] + [%expr fun (_:unit) (_:unit) -> true] | true, ([%type: int] | [%type: int32] | [%type: Int32.t] | [%type: int64] | [%type: Int64.t] | [%type: nativeint] | [%type: Nativeint.t] | [%type: float] | [%type: bool] | diff --git a/src_plugins/ppx_deriving_eq.mllib b/src_plugins/ppx_deriving_eq.mllib deleted file mode 100644 index a6df865..0000000 --- a/src_plugins/ppx_deriving_eq.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_eq diff --git a/src_plugins/ppx_deriving_fold.mllib b/src_plugins/ppx_deriving_fold.mllib deleted file mode 100644 index 4fc6db4..0000000 --- a/src_plugins/ppx_deriving_fold.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_fold diff --git a/src_plugins/ppx_deriving_iter.mllib b/src_plugins/ppx_deriving_iter.mllib deleted file mode 100644 index ae308d5..0000000 --- a/src_plugins/ppx_deriving_iter.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_iter diff --git a/src_plugins/ppx_deriving_make.mllib b/src_plugins/ppx_deriving_make.mllib deleted file mode 100644 index 7f23204..0000000 --- a/src_plugins/ppx_deriving_make.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_make diff --git a/src_plugins/ppx_deriving_map.cppo.ml b/src_plugins/ppx_deriving_map.cppo.ml index 99e10d6..8539937 100644 --- a/src_plugins/ppx_deriving_map.cppo.ml +++ b/src_plugins/ppx_deriving_map.cppo.ml @@ -127,7 +127,8 @@ let str_of_type ~options ~path ({ ptype_loc = loc } as type_decl) = name, [%expr [%e expr_of_typ ~decl:type_decl pld_type] [%e Exp.field (evar "x") (mknoloc (Lident name))]]) in - [%expr fun x -> [%e record fields]] + let annot_typ = Ppx_deriving.core_type_of_type_decl type_decl in + [%expr fun (x:[%t annot_typ]) -> [%e record fields]] | Ptype_abstract, None -> raise_errorf ~loc "%s cannot be derived for fully abstract types" deriver | Ptype_open, _ -> diff --git a/src_plugins/ppx_deriving_map.mllib b/src_plugins/ppx_deriving_map.mllib deleted file mode 100644 index 3b73190..0000000 --- a/src_plugins/ppx_deriving_map.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_map diff --git a/src_plugins/ppx_deriving_ord.cppo.ml b/src_plugins/ppx_deriving_ord.cppo.ml index a534352..5c5e0be 100644 --- a/src_plugins/ppx_deriving_ord.cppo.ml +++ b/src_plugins/ppx_deriving_ord.cppo.ml @@ -70,8 +70,10 @@ and expr_of_typ quoter typ = | { ptyp_desc = Ptyp_constr _ } -> let builtin = not (attr_nobuiltin typ.ptyp_attributes) in begin match builtin, typ with - | true, ([%type: _] | [%type: unit]) -> + | true, [%type: _] -> [%expr fun _ _ -> 0] + | true, [%type: unit] -> + [%expr fun (_:unit) (_:unit) -> 0] | true, ([%type: int] | [%type: int32] | [%type: Int32.t] | [%type: int64] | [%type: Int64.t] | [%type: nativeint] | [%type: Nativeint.t] | [%type: float] | [%type: bool] diff --git a/src_plugins/ppx_deriving_ord.mllib b/src_plugins/ppx_deriving_ord.mllib deleted file mode 100644 index 77e7cfe..0000000 --- a/src_plugins/ppx_deriving_ord.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_ord diff --git a/src_plugins/ppx_deriving_show.cppo.ml b/src_plugins/ppx_deriving_show.cppo.ml index 06a0f2e..12935a1 100644 --- a/src_plugins/ppx_deriving_show.cppo.ml +++ b/src_plugins/ppx_deriving_show.cppo.ml @@ -54,21 +54,21 @@ let pconstrrec name fields = pconstr name [precord ~closed:Closed fields] let wrap_printer quoter printer = Ppx_deriving.quote quoter - [%expr (let fprintf = Format.fprintf in [%e printer]) [@ocaml.warning "-26"]] + [%expr (let fprintf = Ppx_deriving_runtime.Format.fprintf in [%e printer]) [@ocaml.warning "-26"]] let pp_type_of_decl ~options ~path type_decl = let _ = parse_options options in let typ = Ppx_deriving.core_type_of_type_decl type_decl in Ppx_deriving.poly_arrow_of_type_decl - (fun var -> [%type: Format.formatter -> [%t var] -> Ppx_deriving_runtime.unit]) + (fun var -> [%type: Ppx_deriving_runtime.Format.formatter -> [%t var] -> Ppx_deriving_runtime.unit]) type_decl - [%type: Format.formatter -> [%t typ] -> Ppx_deriving_runtime.unit] + [%type: Ppx_deriving_runtime.Format.formatter -> [%t typ] -> Ppx_deriving_runtime.unit] let show_type_of_decl ~options ~path type_decl = let _ = parse_options options in let typ = Ppx_deriving.core_type_of_type_decl type_decl in Ppx_deriving.poly_arrow_of_type_decl - (fun var -> [%type: Format.formatter -> [%t var] -> Ppx_deriving_runtime.unit]) + (fun var -> [%type: Ppx_deriving_runtime.Format.formatter -> [%t var] -> Ppx_deriving_runtime.unit]) type_decl [%type: [%t typ] -> Ppx_deriving_runtime.string] @@ -85,26 +85,26 @@ let rec expr_of_typ quoter typ = | Some printer -> [%expr [%e wrap_printer quoter printer] fmt] | None -> if attr_opaque typ.ptyp_attributes then - [%expr fun _ -> Format.pp_print_string fmt "<opaque>"] + [%expr fun _ -> Ppx_deriving_runtime.Format.pp_print_string fmt "<opaque>"] else - let format x = [%expr Format.fprintf fmt [%e str x]] in + let format x = [%expr Ppx_deriving_runtime.Format.fprintf fmt [%e str x]] in let seq start finish fold typ = [%expr fun x -> - Format.fprintf fmt [%e str start]; + Ppx_deriving_runtime.Format.fprintf fmt [%e str start]; ignore ([%e fold] (fun sep x -> - if sep then Format.fprintf fmt ";@ "; + if sep then Ppx_deriving_runtime.Format.fprintf fmt ";@ "; [%e expr_of_typ typ] x; true) false x); - Format.fprintf fmt [%e str finish];] + Ppx_deriving_runtime.Format.fprintf fmt [%e str finish];] in let typ = Ppx_deriving.remove_pervasives ~deriver typ in match typ with - | [%type: _] -> [%expr fun _ -> Format.pp_print_string fmt "_"] + | [%type: _] -> [%expr fun _ -> Ppx_deriving_runtime.Format.pp_print_string fmt "_"] | { ptyp_desc = Ptyp_arrow _ } -> - [%expr fun _ -> Format.pp_print_string fmt "<fun>"] + [%expr fun _ -> Ppx_deriving_runtime.Format.pp_print_string fmt "<fun>"] | { ptyp_desc = Ptyp_constr _ } -> let builtin = not (attr_nobuiltin typ.ptyp_attributes) in begin match builtin, typ with - | true, [%type: unit] -> [%expr fun () -> Format.pp_print_string fmt "()"] + | true, [%type: unit] -> [%expr fun () -> Ppx_deriving_runtime.Format.pp_print_string fmt "()"] | true, [%type: int] -> format "%d" | true, [%type: int32] | true, [%type: Int32.t] -> format "%ldl" @@ -119,38 +119,38 @@ let rec expr_of_typ quoter typ = | true, [%type: String.t] -> format "%S" | true, [%type: bytes] | true, [%type: Bytes.t] -> - [%expr fun x -> Format.fprintf fmt "%S" (Bytes.to_string x)] + [%expr fun x -> Ppx_deriving_runtime.Format.fprintf fmt "%S" (Bytes.to_string x)] | true, [%type: [%t? typ] ref] -> [%expr fun x -> - Format.pp_print_string fmt "ref ("; + Ppx_deriving_runtime.Format.pp_print_string fmt "ref ("; [%e expr_of_typ typ] !x; - Format.pp_print_string fmt ")"] + Ppx_deriving_runtime.Format.pp_print_string fmt ")"] | true, [%type: [%t? typ] list] -> seq "@[<2>[" "@,]@]" [%expr List.fold_left] typ | true, [%type: [%t? typ] array] -> seq "@[<2>[|" "@,|]@]" [%expr Array.fold_left] typ | true, [%type: [%t? typ] option] -> [%expr function - | None -> Format.pp_print_string fmt "None" + | None -> Ppx_deriving_runtime.Format.pp_print_string fmt "None" | Some x -> - Format.pp_print_string fmt "(Some "; + Ppx_deriving_runtime.Format.pp_print_string fmt "(Some "; [%e expr_of_typ typ] x; - Format.pp_print_string fmt ")"] + Ppx_deriving_runtime.Format.pp_print_string fmt ")"] | true, ([%type: ([%t? ok_t], [%t? err_t]) result] | [%type: ([%t? ok_t], [%t? err_t]) Result.result]) -> [%expr function | Result.Ok ok -> - Format.pp_print_string fmt "(Ok "; + Ppx_deriving_runtime.Format.pp_print_string fmt "(Ok "; [%e expr_of_typ ok_t] ok; - Format.pp_print_string fmt ")" + Ppx_deriving_runtime.Format.pp_print_string fmt ")" | Result.Error e -> - Format.pp_print_string fmt "(Error "; + Ppx_deriving_runtime.Format.pp_print_string fmt "(Error "; [%e expr_of_typ err_t] e; - Format.pp_print_string fmt ")"] + Ppx_deriving_runtime.Format.pp_print_string fmt ")"] | true, ([%type: [%t? typ] lazy_t] | [%type: [%t? typ] Lazy.t]) -> [%expr fun x -> if Lazy.is_val x then [%e expr_of_typ typ] (Lazy.force x) - else Format.pp_print_string fmt "<not evaluated>"] + else Ppx_deriving_runtime.Format.pp_print_string fmt "<not evaluated>"] | _, { ptyp_desc = Ptyp_constr ({ txt = lid }, args) } -> let args_pp = List.map (fun typ -> [%expr fun fmt -> [%e expr_of_typ typ]]) args in let printer = @@ -167,10 +167,10 @@ let rec expr_of_typ quoter typ = let args = List.mapi (fun i typ -> app (expr_of_typ typ) [evar (argn i)]) typs in [%expr fun [%p ptuple (List.mapi (fun i _ -> pvar (argn i)) typs)] -> - Format.fprintf fmt "(@["; + Ppx_deriving_runtime.Format.fprintf fmt "(@["; [%e args |> Ppx_deriving.(fold_exprs - (seq_reduce ~sep:[%expr Format.fprintf fmt ",@ "]))]; - Format.fprintf fmt "@])"] + (seq_reduce ~sep:[%expr Ppx_deriving_runtime.Format.fprintf fmt ",@ "]))]; + Ppx_deriving_runtime.Format.fprintf fmt "@])"] | { ptyp_desc = Ptyp_variant (fields, _, _); ptyp_loc } -> let cases = fields |> List.map (fun field -> @@ -180,15 +180,15 @@ let rec expr_of_typ quoter typ = let label = label.txt in #endif Exp.case (Pat.variant label None) - [%expr Format.pp_print_string fmt [%e str ("`" ^ label)]] + [%expr Ppx_deriving_runtime.Format.pp_print_string fmt [%e str ("`" ^ label)]] | Rtag (label, _, false, [typ]) -> #if OCAML_VERSION >= (4, 06, 0) let label = label.txt in #endif Exp.case (Pat.variant label (Some [%pat? x])) - [%expr Format.fprintf fmt [%e str ("`" ^ label ^ " (@[<hov>")]; + [%expr Ppx_deriving_runtime.Format.fprintf fmt [%e str ("`" ^ label ^ " (@[<hov>")]; [%e expr_of_typ typ] x; - Format.fprintf fmt "@])"] + Ppx_deriving_runtime.Format.fprintf fmt "@])"] | Rinherit ({ ptyp_desc = Ptyp_constr (tname, _) } as typ) -> Exp.case [%pat? [%p Pat.type_ tname] as x] [%expr [%e expr_of_typ typ] x] @@ -246,18 +246,18 @@ let str_of_type ~options ~path ({ ptype_loc = loc } as type_decl) = List.mapi (fun i typ -> app (expr_of_typ quoter typ) [evar (argn i)]) typs in let printer = match args with - | [] -> [%expr Format.pp_print_string fmt [%e str constr_name]] + | [] -> [%expr Ppx_deriving_runtime.Format.pp_print_string fmt [%e str constr_name]] | [arg] -> [%expr - Format.fprintf fmt [%e str ("(@[<2>" ^ constr_name ^ "@ ")]; + Ppx_deriving_runtime.Format.fprintf fmt [%e str ("(@[<2>" ^ constr_name ^ "@ ")]; [%e arg]; - Format.fprintf fmt "@])"] + Ppx_deriving_runtime.Format.fprintf fmt "@])"] | args -> [%expr - Format.fprintf fmt [%e str ("(@[<2>" ^ constr_name ^ " (@,")]; + Ppx_deriving_runtime.Format.fprintf fmt [%e str ("(@[<2>" ^ constr_name ^ " (@,")]; [%e args |> Ppx_deriving.(fold_exprs - (seq_reduce ~sep:[%expr Format.fprintf fmt ",@ "]))]; - Format.fprintf fmt "@,))@]"] + (seq_reduce ~sep:[%expr Ppx_deriving_runtime.Format.fprintf fmt ",@ "]))]; + Ppx_deriving_runtime.Format.fprintf fmt "@,))@]"] in Exp.case (pconstr name' (pattn typs)) printer #if OCAML_VERSION >= (4, 03, 0) @@ -265,17 +265,17 @@ let str_of_type ~options ~path ({ ptype_loc = loc } as type_decl) = let args = labels |> List.map (fun { pld_name = { txt = n }; pld_type = typ } -> [%expr - Format.fprintf fmt "@[%s =@ " [%e str n]; + Ppx_deriving_runtime.Format.fprintf fmt "@[%s =@ " [%e str n]; [%e expr_of_typ quoter typ] [%e evar (argl n)]; - Format.fprintf fmt "@]" + Ppx_deriving_runtime.Format.fprintf fmt "@]" ]) in let printer = [%expr - Format.fprintf fmt [%e str ("@[<2>" ^ constr_name ^ " {@,")]; + Ppx_deriving_runtime.Format.fprintf fmt [%e str ("@[<2>" ^ constr_name ^ " {@,")]; [%e args |> Ppx_deriving.(fold_exprs - (seq_reduce ~sep:[%expr Format.fprintf fmt ";@ "]))]; - Format.fprintf fmt "@]}"] + (seq_reduce ~sep:[%expr Ppx_deriving_runtime.Format.fprintf fmt ";@ "]))]; + Ppx_deriving_runtime.Format.fprintf fmt "@]}"] in Exp.case (pconstrrec name' (pattl labels)) printer #endif @@ -288,16 +288,16 @@ let str_of_type ~options ~path ({ ptype_loc = loc } as type_decl) = let field_name = if i = 0 then expand_path show_opts ~path name else name in let pld_type = {pld_type with ptyp_attributes=pld_attributes@pld_type.ptyp_attributes} in [%expr - Format.fprintf fmt "@[%s =@ " [%e str field_name]; + Ppx_deriving_runtime.Format.fprintf fmt "@[%s =@ " [%e str field_name]; [%e expr_of_typ quoter pld_type] [%e Exp.field (evar "x") (mknoloc (Lident name))]; - Format.fprintf fmt "@]" + Ppx_deriving_runtime.Format.fprintf fmt "@]" ]) in [%expr fun fmt x -> - Format.fprintf fmt "@[<2>{ "; + Ppx_deriving_runtime.Format.fprintf fmt "@[<2>{ "; [%e fields |> Ppx_deriving.(fold_exprs - (seq_reduce ~sep:[%expr Format.fprintf fmt ";@ "]))]; - Format.fprintf fmt "@ }@]"] + (seq_reduce ~sep:[%expr Ppx_deriving_runtime.Format.fprintf fmt ";@ "]))]; + Ppx_deriving_runtime.Format.fprintf fmt "@ }@]"] | Ptype_abstract, None -> raise_errorf ~loc "%s cannot be derived for fully abstract types" deriver | Ptype_open, _ -> @@ -305,7 +305,7 @@ let str_of_type ~options ~path ({ ptype_loc = loc } as type_decl) = in let pp_poly_apply = Ppx_deriving.poly_apply_of_type_decl type_decl (evar (Ppx_deriving.mangle_type_decl (`Prefix "pp") type_decl)) in - let stringprinter = [%expr fun x -> Format.asprintf "%a" [%e pp_poly_apply] x] in + let stringprinter = [%expr fun x -> Ppx_deriving_runtime.Format.asprintf "%a" [%e pp_poly_apply] x] in let polymorphize = Ppx_deriving.poly_fun_of_type_decl type_decl in let pp_type = Ppx_deriving.strong_type_of_type @@ pp_type_of_decl ~options ~path type_decl in @@ -316,14 +316,15 @@ let str_of_type ~options ~path ({ ptype_loc = loc } as type_decl) = pvar (Ppx_deriving.mangle_type_decl (`Prefix "pp") type_decl) in let show_var = pvar (Ppx_deriving.mangle_type_decl (`Prefix "show") type_decl) in + let no_warn_32 = Ppx_deriving.attr_warning [%expr "-32"] in [Vb.mk (Pat.constraint_ pp_var pp_type) (Ppx_deriving.sanitize ~quoter (polymorphize prettyprinter)); - Vb.mk (Pat.constraint_ show_var show_type) (polymorphize stringprinter);] + Vb.mk ~attrs:[no_warn_32] (Pat.constraint_ show_var show_type) (polymorphize stringprinter);] let () = Ppx_deriving.(register (create deriver ~core_type: (Ppx_deriving.with_quoter (fun quoter typ -> - [%expr fun x -> Format.asprintf "%a" (fun fmt -> [%e expr_of_typ quoter typ]) x])) + [%expr fun x -> Ppx_deriving_runtime.Format.asprintf "%a" (fun fmt -> [%e expr_of_typ quoter typ]) x])) ~type_decl_str: (fun ~options ~path type_decls -> [Str.value Recursive (List.concat (List.map (str_of_type ~options ~path) type_decls))]) ~type_decl_sig: (fun ~options ~path type_decls -> diff --git a/src_plugins/ppx_deriving_show.mllib b/src_plugins/ppx_deriving_show.mllib deleted file mode 100644 index 33fe222..0000000 --- a/src_plugins/ppx_deriving_show.mllib +++ /dev/null @@ -1 +0,0 @@ -ppx_deriving_show diff --git a/src_plugins/ppx_deriving_std.ml b/src_plugins/ppx_deriving_std.ml new file mode 100644 index 0000000..e3ea20e --- /dev/null +++ b/src_plugins/ppx_deriving_std.ml @@ -0,0 +1 @@ +(* dummy module to appease dune and older version of OCaml *) |