You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am unsure how important this is in practice, but the encoding of option values makes Some (Some (... None)) equal to None.
Could this be an issue [when using types whose definitions are unknown]?
module M : sig
type t[@@deriving show, yojson]
val x : t
val y : t
end = struct
type t = int option [@@deriving show, yojson]
let x = None
let y = Some 1
end
type t = {
n : string;
v : M.t option;
}[@@deriving show, yojson]
let x = { n = "x"; v = Some M.x; }
let y = { n = "y"; v = Some M.y; }
let roundtrip v =
match of_yojson (to_yojson v) with
| Ok v' ->
if v = v' then
Printf.printf "equal\n%!"
else
Printf.printf "%S vs %S\n%!" (show v) (show v')
| Error _ -> assert false
let () =
roundtrip x;
roundtrip y
The text was updated successfully, but these errors were encountered:
That's the case with any type whose serialization can include null. For example [%of_yojson: unit option] serializes both Some () and None as null. I don't think it's a problem (and it's not really fixable), but that's probably worth mentioning in the "semantics" paragraph.
I am unsure how important this is in practice, but the encoding of
option
values makesSome (Some (... None))
equal toNone
.Could this be an issue [when using types whose definitions are unknown]?
The text was updated successfully, but these errors were encountered: