6 Purely functional state
This chapter covers
- Writing pure stateful APIs by making state updates explicit
- Identifying general repetition in pure state transitions
- Using combinators to abstract over explicit state transitions
- Combining multiple and nested state actions
- Introducing a general state action data type
Working with program state is tricky, and even more so in functional programming, where we value principles such as immutability and eradicating side effects. Mutating state comes at a considerable cost, making programs difficult to reason about and maintain. Fortunately, we have a design pattern at hand to deal with program state in a purely functional way. Applying this pattern allows us to deal with state in a deterministic fashion ...
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.