From 13dd4d972d4c081199c1e5a11ce5e923ecf61584 Mon Sep 17 00:00:00 2001 From: Alain Frisch Date: Thu, 26 Sep 2013 08:36:31 +0000 Subject: [PATCH] Adapt one more example. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14185 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- experimental/frisch/ppx_builder.ml | 31 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/experimental/frisch/ppx_builder.ml b/experimental/frisch/ppx_builder.ml index 262274cb4..32d3edd9e 100644 --- a/experimental/frisch/ppx_builder.ml +++ b/experimental/frisch/ppx_builder.ml @@ -78,20 +78,23 @@ module Main : sig end = struct let gen_builder tdecl = with_default_loc tdecl.ptype_loc (fun () -> gen_builder tdecl) - let builder = object(this) - inherit Ast_mapper.mapper - - method! structure l = - List.flatten - (List.map - (function - | {pstr_desc = Pstr_type tdecls; _} as i -> - i :: (List.flatten (List.map gen_builder tdecls)) - | i -> [this # structure_item i] - ) - l + let builder _args = + let open Ast_mapper in + let super = default_mapper in + {super + with + structure = + (fun this l -> + List.flatten + (List.map + (function + | {pstr_desc = Pstr_type tdecls; _} as i -> + i :: (List.flatten (List.map gen_builder tdecls)) + | i -> [structure_item this i] + ) l + ) ) - end + } - let () = Ast_mapper.main builder + let () = Ast_mapper.run_main builder end