Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stripping the underscore #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ remove: [
["ocamlfind" "remove" "deriving-yojson"]
]
depends: [
"deriving" {>=0.6}
"deriving" {>="0.6"}
"ocamlfind"
"yojson"
]
7 changes: 6 additions & 1 deletion syntax/pa_deriving_yojson.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down