roc
roc copied to clipboard
Derive decoders for tag unions
- [ ] Add
discriminant : List (List U8) -> Decoder Nat fmt | fmt has DecoderFormattingtoDecoderFormattingand updateJson.rocto implement it. - [ ] Derive decoders for tags based on that.
I think we may need to add
## [sequence state stepElem finalizer] decodes a possibly-heterogenous sequence representation into `state`.
sequence : state, (state -> [Keep (Decoder state fmt), Skip]), (state -> Result val DecodeError) -> Decoder val fmt | fmt has DecoderFormatting
which parses a heterogenous list (like that of a tag's payload) in order to support multi-payload tags. There is an example at https://www.notion.so/rwx/Roc-s-Decoding-API-6a9cd9b5c5ec4602b796e8b5a8857697