Book description
Master techniques and concepts of functional programming to deliver safer, simpler, and more effective Kotlin code.In Functional Programming in Kotlin you will learn:
- Functional programming techniques for real-world applications
- Write combinator libraries
- Common structures and idioms in functional design
- Simplicity and modularity (and fewer bugs!)
Functional Programming in Kotlin is a reworked version of the bestselling Functional Programming in Scala, with all code samples, instructions, and exercises translated into the powerful Kotlin language. In this authoritative guide, you’ll take on the challenge of learning functional programming from first principles. Complex concepts are demonstrated through exercises that you’ll love to test yourself against. You’ll start writing Kotlin code that’s easier to read, easier to reuse, better for concurrency, and less prone to bugs and errors.
About the Technology
Improve performance, increase maintainability, and eliminate bugs! How? By programming the functional way. Kotlin provides strong support for functional programming, taking a pragmatic approach that integrates well with OO codebases. By applying the techniques you’ll learn in this book, your code will be safer, less prone to errors, and much easier to read and reuse.
About the Book
Functional Programming in Kotlin teaches you how to design and write Kotlin applications using typed functional programming. Offering clear examples, carefully-presented explanations, and extensive exercises, it moves from basic subjects like types and data structures to advanced topics such as stream processing. This book is based on the bestseller Functional Programming in Scala by Rúnar Bjarnason and Paul Chiusano.
What's Inside
- Functional programming techniques for real-world situations
- Common structures and idioms in functional design
- Simplicity, modularity, and fewer bugs!
About the Reader
For Kotlin developers. No functional programming experience required.
About the Authors
Marco Vermeulen has two decades of programming experience on the JVM.
Rúnar Bjarnason and Paul Chiusano are the authors of Functional Programming in Scala.
Quotes
The best book for any developer who is serious about leveling up their Kotlin skills!
- Gustavo Gomes, Troido
An elegant and rigorous introduction to functional programming.
- Marco Carnini, Features Analytics
A comprehensive guide that leverages Kotlin’s basic and more advanced functional programming capabilities!
- Jean-François Morin, Laval University
An excellent springboard for enabling Kotlin developers to embrace coding in the functional style.
- Garth Gilmour, Instil Software
A fantastic book if you want to finally understand what all the fuss about FP is about.
- Felipe Fernández Domínguez, Gradle
Table of contents
- Functional Programming with Kotlin
- Copyright
- contents
- front matter
- Part 1. Introduction to functional programming
- 1 What is functional programming?
- 2 Getting started with functional programming in Kotlin
- 3 Functional data structures
- 4 Handling errors without exceptions
- 5 Strictness and laziness
- 6 Purely functional state
- Part 2. Functional design and combinator libraries
- 7 Purely functional parallelism
- 8 Property-based testing
- 9 Parser combinators
- Part 3. Common structures in functional design
- 10 Monoids
- 11 Monads and functors
-
12 Applicative and traversable functors
- 12.1 Generalizing monads for reusability
- 12.2 Applicatives as an alternative abstraction to the monad
- 12.3 The difference between monads and applicative functors
- 12.4 The advantages of applicative functors
- 12.5 Reasoning about programs through the applicative laws
- 12.6 Abstracting traverse and sequence using traversable functors
-
12.7 Using Traversable to iteratively transform higher kinds
- 12.7.1 From monoids to applicative functors
- 12.7.2 Traversing collections while propagating state actions
- 12.7.3 Combining traversable structures
- 12.7.4 Traversal fusion for single pass efficiency
- 12.7.5 Simultaneous traversal of nested traversable structures
- 12.7.6 Pitfalls and workarounds for monad composition
- Summary
- Part 4. Effects and I/O
-
13 External effects and I/O
- 13.1 Factoring effects out of an effectful program
- 13.2 Introducing the IO type to separate effectful code
- 13.3 Avoiding stack overflow errors by reification and trampolining
- 13.4 A more nuanced IO type
- 13.5 Non-blocking and asynchronous I/O
- 13.6 A general-purpose IO type
- 13.7 Why the IO type is insufficient for streaming I/O
- Summary
- 14 Local effects and mutable state
- 15 Stream processing and incremental I/O
-
Appendix A. Exercise hints and tips
- A.1 Chapter 3: Functional data structures
- A.2 Chapter 4: Handling errors without exceptions
- A.3 Chapter 5: Strictness and laziness
- A.4 Chapter 6: Purely functional state
- A.5 Chapter 7: Purely functional parallelism
- A.6 Chapter 8: Property-based testing
- A.7 Chapter 9: Parser combinators
- A.8 Chapter 10: Monoids
- A.9 Chapter 11: Monads and functors
- A.10 Chapter 12: Applicative and traversable functors
- A.11 Chapter 13: External effects and I/O
- A.12 Chapter 14: Local effects and mutable state
- A.13 Chapter 15: Stream processing and incremental I/O
-
Appendix B. Exercise solutions
- B.1 Before you proceed to the solutions
- B.2 Getting started with functional programming
-
B.3 Functional data structures
- Exercise 3.1
- Exercise 3.2
- Exercise 3.3
- Exercise 3.4
- Exercise 3.5
- Exercise 3.6
- Exercise 3.7
- Exercise 3.8
- Exercise 3.9
- Exercise 3.10
- Exercise 3.11
- Exercise 3.12 (Hard)
- Exercise 3.13
- Exercise 3.14 (Hard)
- Exercise 3.15
- Exercise 3.16
- Exercise 3.17
- Exercise 3.18
- Exercise 3.19
- Exercise 3.20
- Exercise 3.21
- Exercise 3.22
- Exercise 3.23
- Exercise 3.24
- Exercise 3.25
- Exercise 3.26
- Exercise 3.27
- Exercise 3.28
- B.4 Handling errors without exceptions
- B.5 Strictness and laziness
- B.6 Purely functional state
- B.7 Purely functional parallelism
- B.8 Property-based testing
- B.9 Parser combinators
-
B.10 Monoids
- Exercise 10.1
- Exercise 10.2
- Exercise 10.3
- Exercise 10.4
- Exercise 10.5
- Exercise 10.6
- Exercise 10.7
- Exercise 10.8 (Hard/Optional)
- Exercise 10.9 (Hard/Optional)
- Exercise 10.10
- Exercise 10.11
- Exercise 10.12
- Exercise 10.13
- Exercise 10.14
- Exercise 10.15
- Exercise 10.16
- Exercise 10.17
- Exercise 10.18
- Exercise 10.19
-
B.11 Monads and functors
- Exercise 11.1
- Exercise 11.2
- Exercise 11.3
- Exercise 11.4
- Exercise 11.5
- Exercise 11.6 (Hard)
- Exercise 11.7
- Exercise 11.8 (Hard)
- Exercise 11.9
- Exercise 11.10
- Exercise 11.11
- Exercise 11.12
- Exercise 11.13 (Hard/Optional)
- Exercise 11.14 (Hard/Optional)
- Exercise 11.15 (Hard/Optional)
- Exercise 11.16
- Exercise 11.17
- Exercise 11.18
- Exercise 11.19 (Hard)
-
B.12 Applicative and traversable functors
- Exercise 12.1
- Exercise 12.2 (Hard)
- Exercise 12.3
- Exercise 12.4
- Exercise 12.5
- Exercise 12.6
- Exercise 12.7 (Hard)
- Exercise 12.8
- Exercise 12.9
- Exercise 12.10
- Exercise 12.11
- Exercise 12.12 (Hard)
- Exercise 12.13 (Hard)
- Exercise 12.14
- Exercise 12.15
- Exercise 12.16
- Exercise 12.17
- Exercise 12.18 (Hard)
- Exercise 12.19 (Hard/Optional)
- B.13 External effects and I/O
- B.14 Local effects and mutable state
- B.15 Stream processing and incremental I/O
- Appendix C. Higher-kinded types
- Appendix D. Type classes
- index
Product information
- Title: Functional Programming in Kotlin
- Author(s):
- Release date: September 2021
- Publisher(s): Manning Publications
- ISBN: 9781617297168
You might also like
book
Functional Programming in Scala
Functional Programming in Scala is a serious tutorial for programmers looking to learn FP and apply …
book
Functional Kotlin
Learn how to apply Functional Programming with Kotlin to real-life projects with popular libraries like Arrow. …
book
Functional Programming in Java
Functional Programming in Java teaches Java developers how to incorporate the most powerful benefits of functional …
video
Advanced Kotlin Programming
Designed for developers who already have a basic understanding of Kotlin, this video course examines some …