Roc-Solid Intuition for JSON Decoding
summary
Builds a reusable JSON decoder library in Roc that models JSON as tag unions (string, number as unsigned 64‑bit int, boolean, object, array) and models failures with a DecodingError tag union returned in a Result type. Implements primitive decoders, an array decoder using mapTry, a field decoder for objects, combinators (map2/map3) to assemble records, and a dictionary‑based tag decoder for discriminated unions, cutting the original boilerplate roughly in half.
AI-written summary · about
chapters (16)
- 0:00Welcome
- 0:46Modeling JSON with tag unions
- 3:35Decoding simple types
- 7:46Handling errors
- 11:00Decoding complex lists
- 13:49Boilerplate and concerns
- 15:13Reusable primitive decoders
- 16:38Decoding arrays generically
- 18:46Decoding objects to records
- 21:58Combining field decoders
- 23:24Introducing map2
- 26:09Decoding unions with discriminators
- 28:18Building a tag decoder
- 30:44Refactoring to library
- 31:48Summary of benefits
- 32:29Q&A
related talks
46mSimple Functional Effects with Tag Unions
28mAdopting Cats
53mUnderstanding parser combinators: a deep dive
40mADTs For The Win!
34mFunctional refactoring
56mCalculating Intuitionistic Logic in Scala
46mDesign for errors - An introduction to Domain Modeling with a bit of Arrow
02mDesigning your Data: The Bread and Butter of APL Performance
