14 Local effects and mutable state
This chapter covers
- Defining referential transparency in terms of mutable state
- Hiding local state change through typed scoping of effects
- Developing a domain-specific language (DSL) to encapsulate mutable state
- Establishing an algebra and interpreter for running programs
In chapter 1, we introduced the concept of referential transparency, setting the premise for purely functional programming. We declared that pure functions can’t mutate data in place or interact with the external world. In chapter 13, we learned that this isn’t exactly true. We can write purely functional and compositional programs that describe interactions with the outside world. These programs are unaware that they can be evaluated with ...
Get Functional Programming in Kotlin now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.