Skip to content

Commit

Permalink
Merge pull request #7 from ocaml-ppx/remove-type-conv-references
Browse files Browse the repository at this point in the history
Remove references to type_conv
  • Loading branch information
xclerc authored Mar 22, 2018
2 parents ea6c768 + 207a0b2 commit 3c8fd46
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ above.

Derivers
--------
The `Ppxlib.Type_conv` module factors out functionality needed by
The `Ppxlib.Deriving` module factors out functionality needed by
different preprocessors that generate code from type specifications. Example
libraries currently depending on `type_conv`:
libraries currently depending on `Deriving`:

- `ppx_bin_prot`;
- `ppx_compare`;
Expand All @@ -288,24 +288,24 @@ libraries currently depending on `type_conv`:

Compatibility with [ppx_deriving](https://github.com/ocaml-ppx/ppx_deriving)
----------------------------------------------------------------------------
`Ppxlib.Type_conv`-based code generators are meant to be used with
`Ppxlib.Driver`. However `Type_conv` allows to export a compatible
`Ppxlib.Deriving`-based code generators are meant to be used with
`Ppxlib.Driver`. However `Deriving` allows to export a compatible
`ppx_deriving` plugin. By default, when not linked as part of a driver,
packages using `Type_conv` will just use `ppx_deriving`.
packages using `Deriving` will just use `ppx_deriving`.

So for instance this will work as expected using `ppx_deriving`:

ocamlfind ocamlc -c -package ppx_sexp_conv foo.ml

For end users, the main advantage of using `Type_conv`-based generators is that
For end users, the main advantage of using `Deriving`-based generators is that
it will catch typos and attributes misplacement. For instance:

```
# type t = int [@@derivin sexp]
Error: Attribute `derivin' was not used
Hint: Did you mean deriving?
# type t = int [@@deriving sxp]
Error: ppxlib_type_conv: 'sxp' is not a supported type type-conv generator
Error: ppxlib_deriving: 'sxp' is not a supported type deriving generator
Hint: Did you mean sexp?
# type t = int [@deriving sexp]
Error: Attribute `deriving' was not used
Expand All @@ -318,7 +318,7 @@ Deriving Syntax
---------------
This section is only relevant if you are not using `ppx_deriving`.

`Type_conv` interprets the `[@@deriving ...]` attributes on type declarations,
`Deriving` interprets the `[@@deriving ...]` attributes on type declarations,
exception declarations and extension constructor declarations:

```
Expand All @@ -327,7 +327,7 @@ type t = A | B [@@deriving sexp, bin_io]

`sexp` and `bin_io` are called generators. They are functions that generate
code given the declaration. These functions are implemented by external
libraries such as `ppx_sexp_conv` or `ppx_bin_prot`. `Type_conv` itself
libraries such as `ppx_sexp_conv` or `ppx_bin_prot`. `Deriving` itself
provides no generator, it does only the dispatch.

Generators can take arguments. This is done using the following syntax:
Expand Down Expand Up @@ -372,7 +372,7 @@ types (`int`, `string`, `list`, ...).

Traverse (and Traverse_builtins)
================================
`Ppxlib_traverse` is a `type_conv` plugin generating open recursion classes
`Ppxlib_traverse` is a `Deriving` plugin generating open recursion classes
from type definition. Users can overwrite a specific method of the generated
classes in order to specialize the recursion on specific nodes.
`Ppxlib_traverse` is in particular used to generate the open recursion classes
Expand Down
2 changes: 1 addition & 1 deletion src/context_free.ml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ let sort_attr_inline l =

(* Returns the code generated by attribute handlers. We don't remove these attributes, as
another pass might interpret them later. For instance both ppx_deriving and
ppxlib_type_conv interprets [@@deriving] attributes.
ppxlib_deriving interprets [@@deriving] attributes.
This complexity is horrible, but in practice we don't care as [attrs] is always a list
of one element; it only has [@@deriving].
Expand Down
2 changes: 1 addition & 1 deletion src/context_free.mli
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module Rule : sig

(** The rest of this API is for rewriting rules that apply when a certain attribute is
present. The API is not complete and is currently only enough to implement
type_conv. *)
deriving. *)

(** Match the attribute on a group of items, such as a group of recursive type
definitions (Pstr_type, Psig_type). The expander will be triggered if any of the
Expand Down
12 changes: 6 additions & 6 deletions src/deriving.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ module Generator = struct
List.iter args ~f:(fun (label, e) ->
if String.is_empty label then
Location.raise_errorf ~loc:e.pexp_loc
"ppxlib_type_conv: generator arguments must be labelled");
"Ppxlib.Deriving: generator arguments must be labelled");
Option.iter (List.find_a_dup args ~compare:(fun (a, _) (b, _) -> String.compare a b))
~f:(fun (label, e) ->
Location.raise_errorf ~loc:e.pexp_loc
"ppxlib_type_conv: argument labelled '%s' appears more than once" label);
"Ppxlib.Deriving: argument labelled '%s' appears more than once" label);
let accepted_args = merge_accepted_args generators in
List.iter args ~f:(fun (label, e) ->
if not (Set.mem accepted_args label) then
Expand All @@ -170,7 +170,7 @@ module Generator = struct
| Some s -> ".\n" ^ s
in
Location.raise_errorf ~loc:e.pexp_loc
"ppxlib_type_conv: generator '%s' doesn't accept argument '%s'%s"
"Ppxlib.Deriving: generator '%s' doesn't accept argument '%s'%s"
name label spellcheck_msg);
;;

Expand Down Expand Up @@ -297,7 +297,7 @@ module Deriver = struct
""
in
Location.raise_errorf ~loc:name.loc
"ppxlib_type_conv: '%s' is not a supported %s type-conv generator%s"
"Ppxlib.Deriving: '%s' is not a supported %s deriving generator%s"
name.txt field.name spellcheck_msg
;;

Expand All @@ -322,7 +322,7 @@ module Deriver = struct
match args with
| Args l -> l
| Unknown_syntax (loc, msg) ->
Location.raise_errorf ~loc "ppxlib_type_conv: %s" msg)
Location.raise_errorf ~loc "Ppxlib.Deriving: %s" msg)
| Some _ ->
(* It's not one of ours, ignore it. *)
None)
Expand Down Expand Up @@ -373,7 +373,7 @@ module Deriver = struct
| None -> ()
| Some f ->
let extension = Extension.declare name Expression Ast_pattern.(ptyp __) f in
Driver.register_transformation ("ppxlib_type_conv." ^ name)
Driver.register_transformation ("Ppxlib.Deriving." ^ name)
~rules:[ Context_free.Rule.extension extension ]);
name
;;
Expand Down
2 changes: 1 addition & 1 deletion src/deriving.mli
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module Generator : sig
-> 'output_ast
end with type deriver := t

(** Register a new type-conv generator.
(** Register a new deriving generator.
The various arguments are for the various items on which derivers
can be attached in structure and signatures.
Expand Down

0 comments on commit 3c8fd46

Please sign in to comment.