Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Unreleased
-----

* Add location info to `create`, `eq`, `iter`, `make`, `ord`, `show`
#297
(@arvidj)

6.1.1
-----

Expand Down
8 changes: 8 additions & 0 deletions src_plugins/create/ppx_deriving_create.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,17 @@ let sig_of_type ({ ptype_loc = loc } as type_decl) =
[Sig.value (Val.mk (mknoloc (Ppx_deriving.mangle_type_decl (`Prefix deriver) type_decl)) typ)]

let impl_generator = Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, type_decls) ->
let str_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> str_of_type type_decl
in
[Str.value Nonrecursive (List.concat (List.map str_of_type type_decls))])

let intf_generator = Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, type_decls) ->
let sig_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> sig_of_type type_decl
in
List.concat (List.map sig_of_type type_decls))

let deriving: Deriving.t =
Expand Down
8 changes: 8 additions & 0 deletions src_plugins/eq/ppx_deriving_eq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,17 @@ let str_of_type ({ ptype_loc = loc } as type_decl) =
(Ppx_deriving.sanitize ~quoter (eta_expand (polymorphize comparator)))]

let impl_generator = Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, type_decls) ->
let str_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> str_of_type type_decl
in
[Str.value Recursive (List.concat (List.map str_of_type type_decls))])

let intf_generator = Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, type_decls) ->
let sig_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> sig_of_type type_decl
in
List.concat (List.map sig_of_type type_decls))

let deriving: Deriving.t =
Expand Down
8 changes: 8 additions & 0 deletions src_plugins/iter/ppx_deriving_iter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,17 @@ let sig_of_type type_decl =
(polymorphize [%type: [%t typ] -> Ppx_deriving_runtime.unit]))]

let impl_generator = Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, type_decls) ->
let str_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> str_of_type type_decl
in
[Str.value Recursive (List.concat (List.map str_of_type type_decls))])

let intf_generator = Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, type_decls) ->
let sig_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> sig_of_type type_decl
in
List.concat (List.map sig_of_type type_decls))

let deriving: Deriving.t =
Expand Down
8 changes: 8 additions & 0 deletions src_plugins/make/ppx_deriving_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ let partition_result l =
List.rev errors, List.rev oks

let impl_generator =
let str_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> str_of_type type_decl
in
Deriving.Generator.V2.make_noarg (fun ~ctxt (_, type_decls) ->
match partition_result (List.map str_of_type type_decls) with
| _, (_::_ as vbs) -> [Str.value Nonrecursive vbs]
Expand All @@ -204,6 +208,10 @@ let impl_generator =
errors)

let intf_generator =
let sig_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> sig_of_type type_decl
in
Deriving.Generator.V2.make_noarg (fun ~ctxt (_, type_decls) ->
match partition_result (List.map sig_of_type type_decls) with
| _, (_::_ as vds) -> vds
Expand Down
8 changes: 8 additions & 0 deletions src_plugins/ord/ppx_deriving_ord.ml
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,17 @@ let str_of_type ({ ptype_loc = loc } as type_decl) =
(Ppx_deriving.sanitize ~quoter (eta_expand (polymorphize comparator)))]

let impl_generator = Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, type_decls) ->
let str_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> str_of_type type_decl
in
[Str.value Recursive (List.concat (List.map str_of_type type_decls))])

let intf_generator = Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, type_decls) ->
let sig_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> sig_of_type type_decl
in
List.concat (List.map sig_of_type type_decls))

let deriving: Deriving.t =
Expand Down
10 changes: 9 additions & 1 deletion src_plugins/show/ppx_deriving_show.ml
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,19 @@ let impl_generator = Deriving.Generator.V2.make impl_args (fun ~ctxt (_, type_de
| Some with_path -> with_path
| None -> true (* true by default *)
in
[Str.value Recursive (List.concat (List.map (str_of_type ~with_path ~path) type_decls))])
let str_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> str_of_type ~with_path ~path type_decl
in
[Str.value Recursive (List.concat (List.map str_of_type type_decls))])

let intf_args = Deriving.Args.(empty +> arg "with_path" (Ast_pattern.ebool __))

let intf_generator = Deriving.Generator.V2.make intf_args (fun ~ctxt:_ (_, type_decls) _with_path ->
let sig_of_type type_decl =
Ast_helper.with_default_loc type_decl.ptype_loc @@
fun () -> sig_of_type type_decl
in
List.concat (List.map sig_of_type type_decls))

let deriving: Deriving.t =
Expand Down