

What is the "reify to an interpreter" refactoring?
May 8, 2023
Explore the fascinating 'reify to an interpreter' refactoring technique that transforms functions into data representations. The discussion highlights how this approach can streamline the management of mutation functions. A fun pizza analogy illustrates the concept, making it easier to grasp how state changes can be tracked more effectively. This innovative method promises to enhance your coding practices and understanding of functional programming.
AI Snips
Chapters
Transcript
Episode notes
Mutation Functions as Data
- Mutation functions change a value by taking the current value and returning a modified version. - These functions are tough to record, so turning them into data representations helps keep track of changes.
Refactoring Functions to Data
- Create a new function with the current value as the first argument and operation data as the second. - Represent operations as alternatives with names matching original functions and arguments inside.
Working Interpreter from Data Ops
- The resulting interpreter applies data-represented operations serially to state. - You get a mutation function taking state and an operation in data form, which perfectly models changes over time.