Skip to content

Commit

Permalink
fix(test): Wanted ml file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin COMBRIAT committed Sep 28, 2019
1 parent 7c2f443 commit d0393b9
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/ppx/test/Wanted.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,38 @@ module User =
type _ field =
| Email: string field
| Age: int field
| Hobbies: int -> string option field
| Hobbies: string array field
| HobbiesAt: int -> string option field
| HobbiesAtExn: int -> string field
let get : 'value . t -> 'value field -> 'value= fun (type value) ->
(fun t ->
fun field ->
match field with
| Email -> t.email
| Age -> t.age
| Hobbies index ->
(try Some ((t.hobbies).(index)) with | _ -> None) : t ->
value
field ->
value)
| Hobbies -> t.hobbies
| HobbiesAt index ->
(try Some ((t.hobbies).(index)) with | _ -> None)
| HobbiesAtExn index -> (t.hobbies).(index) : t ->
value field ->
value)
let set : 'value . t -> 'value field -> 'value -> t= fun (type value) ->
(fun t ->
fun field ->
fun value ->
match field with
| Email -> { t with email = value }
| Age -> { t with age = value }
| Hobbies index ->
| Hobbies -> { t with hobbies = value }
| HobbiesAt index ->
(match value with
| Some value ->
((t.hobbies).(index) <- value;
{ t with hobbies = (t.hobbies) })
| None -> hobbies) : t -> value field -> value -> t)
end
| None -> t)
| HobbiesAtExn index ->
((t.hobbies).(index) <- value;
{ t with hobbies = (t.hobbies) }) : t ->
value field ->
value -> t)
end

0 comments on commit d0393b9

Please sign in to comment.