-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
type mytype = Int64.t
let mytype_of_json = function
| `Float f -> Int64.of_float f
| json -> raise (Melange_json.of_json_error ~json "expected a float")
let mytype_to_json i = Int64.to_string i
type my_record = {
a : string;
my_value : mytype;
b : string;
}
[@@deriving json]gives the error :
Error: This expression has type (string * [> `String of string ]) list
but an expression was expected of type (string * string) list
Type [> `String of string ] is not compatible with type string
located on the whole of the my_record type definition.
This is quite confusing when the actual error is that mytype_to_json does not return a json but a string. I don't know if something can be done about the location of the error, but at a type constraint could be put on the usage of mytype_to_json so that is error is more like expected Melange_json.t, got string instead of mentioning a tuple and a list.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels