I am a bit confused by how we decode records.
record :
state,
(state, Str -> [Keep (Decoder state state err), Skip]),
(state -> Result val err)
-> Decoder state val err where state implements DecoderFormatting
Specifically I am confused by Skip
. If we are decoding a record and find an unknown field, do we really want to skip it in decoding? I would assume that we would want to return an error on extraneous fields existing? Maybe with a way to explicitly skip some fields? Just a bit confused by this design.
i believe it is for unknown fields yes
it feels like deciding whether that should error or not should be a decision of the concrete decoder
Ah yeah, I guess that could be a config stored in the decoder state. Was thinking it might be nice to be a per record decision instead of a whole decoder decision. But I'm sure with opaque types and custom implementations, the state could be temporarily modified to enable/disable this feature.
It's configurable in Json implementation, to either skipp or fail I think.
Cool, so definitely a solved problem. Though only configurable at the whole decoder level. Cause to set it for a specific sub decoder would take adding the configuration to skip/fail to EncoderFormatting.
If that ends up being needed, it can be added later.
Related question to this api: (state, Str -> [Keep (Decoder state state err), Skip]),
Record decoding requires a string field name. I guess for binary formats that don't include field names, this means we have to decode records as tuples and then map them to a record? Cause the decoder can never know field names?
Last updated: Jul 06 2025 at 12:14 UTC