14 Local effects and mutable state
This chapter covers
- Introducing mutable state
- Discussing the
ST
monad - Providing a better definition of referential transparency
In the first chapter of this book, 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 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 interpreted with an evaluator that has an effect on the world.
In this chapter, we’ll develop a more mature concept of referential transparency. ...
Get Functional Programming in Scala, Second Edition 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.