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, and start writing Kotlin code that’s easier to read, easier to reuse, better for concurrency, and less prone to bugs and errors.
1.1.2 A functional solution: removing the side effects
1.2 Exactly what is a (pure) function?
1.3 Referential transparency, purity, and the substitution model
1.4 What you will learn in this book
2 Getting started with functional programming in Kotlin
2.1 Introducing Kotlin as language: an example
2.2 Running our program
2.3 Objects, scopes and namespaces
2.4 Higher-order functions: passing functions to functions
2.4.1 A short detour: writing loops functionally
2.4.2 Writing our first higher-order function
2.5 Polymorphic functions: abstracting over types
2.5.1 An example of a polymorphic function
2.5.2 Calling HOFs with anonymous functions
2.6 Following types to implementations
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
12 Applicative and traversable functors
Part 4: Effects and I/O
13 External effects and I/O
14 Local effects and mutable state
15 Stream processing and incremental I/O
Appendix A: Appendix A: Exercise solutions
About the Technology
Kotlin is a new JVM language designed to interoperate with Java and offer an improved developer experience for creating new applications. It’s already a top choice for writing web services, and Android apps. Although it preserves Java’s OO roots, Kotlin really shines when you adopt a functional programming mindset. By learning the core principles and practices of functional programming outlined in this book, you’ll start writing code that’s easier to read, easier to test and reuse, better for concurrency, and less prone to bugs.
About the book
Functional Programming in Kotlin is a serious tutorial for programmers looking to learn FP and apply it to the everyday business of coding. Based on the bestselling Functional Programming in Scala, this book guides intermediate Java and Kotlin programmers from basic techniques to advanced topics in a logical, concise, and clear progression. In it, you'll find concrete examples and exercises that open up the world of functional programming. The book will deliver practical mastery of FP using Kotlin and a valuable perspective on program design that you can apply to other languages.
Functional programming techniques for real-world applications
Write combinator libraries
Identify common structures and idioms in functional design
Code for simplicity, modularity, and fewer bugs
About the reader
For intermediate Kotlin and Java developers. No experience with functional programming is required.
Marco Vermeulen has almost two decades of programming experience on the JVM, with much of that time spent on functional programming using Scala and Kotlin.
Rúnar Bjarnason and Paul Chiusano are the authors of Functional Programming in Scala, on which this book is based. They are internationally-recognized experts in functional programming and the Scala programming language.