The visit_variant function in the visitor record is not meaningfully used and should be removed in favor of passing around a continuation function directly.
And following the types. The end result should be that the data deserializers, like JSON, take visitor that is really a continuation we can call De.deserialize on:
- let deserialize_variant self { reader; _ } visitor ~name:_ ~variants:_ =
+ let deserialize_variant self { reader; _ } de ~name:_ ~variants:_ =
Parser.skip_space reader;
match Parser.peek reader with
| Some '{' ->
let* () = Parser.read_object_start reader in
Parser.skip_space reader;
- let* value = Visitor.visit_variant self visitor in
+ let* value = De.deserialize self de in
Parser.skip_space reader;
let* () = Parser.read_object_end reader in
Ok value
| Some '"' -> Visitor.visit_variant self visitor
| _ -> assert false
The
visit_variant
function in the visitor record is not meaningfully used and should be removed in favor of passing around a continuation function directly.We can start by removing it from here: https://github.com/serde-ml/serde/blob/73251df58654b232fa0d7eb1daff1f566f65396d/serde/serde.ml#L400-L404
And following the types. The end result should be that the data deserializers, like JSON, take
visitor
that is really a continuation we can callDe.deserialize
on: