From bd6eb2e8c75ee3a483bfc05a283ba5d9f2b95f48 Mon Sep 17 00:00:00 2001 From: William Le Ferrand Date: Mon, 23 Mar 2015 22:45:20 -0700 Subject: [PATCH 1/2] stripping the underscore --- opam | 1 - syntax/pa_deriving_yojson.ml | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/opam b/opam index 91ab32b..b0176b3 100644 --- a/opam +++ b/opam @@ -12,7 +12,6 @@ remove: [ ["ocamlfind" "remove" "deriving-yojson"] ] depends: [ - "deriving" {>=0.6} "ocamlfind" "yojson" ] diff --git a/syntax/pa_deriving_yojson.ml b/syntax/pa_deriving_yojson.ml index ced3ff0..e565a95 100644 --- a/syntax/pa_deriving_yojson.ml +++ b/syntax/pa_deriving_yojson.ml @@ -125,7 +125,12 @@ module Builder(Generator : Defs.Generator) = struct method record ?eq ctxt tname params constraints fields = - let strip_underscore s = s in + let strip_underscore s = + if String.length s > 0 && s.[0] = '_' then + String.sub s 1 (String.length s - 1) + else + s + in let all = List.map (fun (name,ty,_) -> name,strip_underscore name,ty) fields in let from_json = let l = List.map (fun (fname,strip_name,ty) -> From 3431c7c473ec0c0645dbf4ffa420f2f181ff087b Mon Sep 17 00:00:00 2001 From: William Le Ferrand Date: Mon, 23 Mar 2015 22:47:39 -0700 Subject: [PATCH 2/2] typo fix --- opam | 1 + 1 file changed, 1 insertion(+) diff --git a/opam b/opam index b0176b3..37a9180 100644 --- a/opam +++ b/opam @@ -12,6 +12,7 @@ remove: [ ["ocamlfind" "remove" "deriving-yojson"] ] depends: [ + "deriving" {>="0.6"} "ocamlfind" "yojson" ]