Imported Upstream version 0.2
[pkg-ocaml-deriving-ocsigen.git] / syntax / pa_deriving_tc.ml
blob65631e43226e8ed2be051ee0699758a87b1d667f
1 (* Copyright Grégoire Henry 2010.
2 This file is free software, distributed under the MIT license.
3 See the file COPYING for details.
4 *)
6 (* Registering type derivers into type-conv. *)
8 open Camlp4.PreCast
10 open Pa_deriving_common.Base
11 open Pa_deriving_common.Type
12 open Pa_deriving_common.Extend
14 let derive deriver types =
15 let loc = Ast.loc_of_ctyp types in
16 let decls = display_errors loc Translate.decls types in
17 display_errors loc deriver (loc, decls)
19 let register name (deriver, sigderiver) =
20 let name = String.uncapitalize name in
21 Pa_type_conv.add_generator name (derive deriver);
22 Pa_type_conv.add_sig_generator name (derive sigderiver)
24 let _ = add_register_hook register