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
When encoding a value, it seems like it's wasteful to write a field whose value is the default one. That's especially true if there's many such fields.
Alternatively, could we even encode, not from a datatype (Foo_types.bar), but from its smart constructor? As in, why build a value of type Foo_types.bar just to encode it immediately, when we can have val write_bar : ?x:int -> ?y:bool -> ?z:string -> encoder -> unit. That should make it more clear which fields are set or not.
edit: of course I forget, but a cool aspect of writing directly from the function, is that one could potentially replace lists by _ Seq.t so they're generated on demand.
The text was updated successfully, but these errors were encountered:
When encoding a value, it seems like it's wasteful to write a field whose value is the default one. That's especially true if there's many such fields.
Alternatively, could we even encode, not from a datatype (
Foo_types.bar
), but from its smart constructor? As in, why build a value of typeFoo_types.bar
just to encode it immediately, when we can haveval write_bar : ?x:int -> ?y:bool -> ?z:string -> encoder -> unit
. That should make it more clear which fields are set or not.edit: of course I forget, but a cool aspect of writing directly from the function, is that one could potentially replace lists by
_ Seq.t
so they're generated on demand.The text was updated successfully, but these errors were encountered: