Group Group Group Group Group Group Group Group Group Group Shape Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group Group
Skip to Content
  • iii. Dedications
  • More
    • NewsletterNewsletter
    • ForumsForums
Sign In
Create a free account
  • Search
  • Notebook
  • Customise
Pro

Functional Programming in Kotlin by Tutorials

First Edition Kotlin 1.6, Android 12, IntelliJ IDEA 2022

Before You Begin

Section 0: 5 chapters
  • i. What You Need
  • ii. Book Source Code & Forums
  • iii. Dedications
  • iv. About the Team
  • v. Introduction
    • How to read this book

Section I: Functional Programming Fundamentals

Section 1: 8 chapters
  • 1. Why Functional Programming
    • 1.1 Using a declarative approach
    • 1.2 Higher-order functions
    • 1.3 Composition
    • 1.4 Pure functions and testability
    • 1.5 Exception handling
    • 1.6 Key points
    • 1.7 Where to go from here?
  • 2. Function Fundamentals
    • 2.1 What is a function?
    • 2.2 Introduction to category theory
    • 2.3 Category and logic
    • 2.4 Initial and terminal objects
    • 2.5 Category of types and functions
    • 2.6 Do types and functions define a category?
    • 2.7 Initial and terminal objects
    • 2.8 Types and sets
    • 2.9 Function types
    • 2.10 Challenges
    • 2.11 Key points
    • 2.12 Where to go from here?
  • 3. Functional Programming Concepts
    • 3.1 Pure functions
    • 3.2 Why are pure functions important?
    • 3.3 Referential transparency and the substitution model
    • 3.4 Side effects
    • 3.5 Challenges
    • 3.6 Key points
    • 3.7 Where to go from here?
  • 4. Expression Evaluation, Laziness & More About Functions
    • 4.1 Expression evaluation order
    • 4.2 Understanding lambda expressions
    • 4.3 Lazy evaluation
    • 4.4 Memoization
    • 4.5 Create a lazy stream with Kotlin
    • 4.6 Normal-order evaluation
    • 4.7 Challenges
    • 4.8 Key points
    • 4.9 Where to go from here?
  • 5. Higher-Order Functions
    • 5.1 Imperative vs. declarative approach
    • 5.2 Higher-order functions
    • 5.3 Functional interfaces
    • 5.4 Using lambda expressions as input and output
    • 5.5 Challenges
    • 5.6 Key points
    • 5.7 Where to go from here?
  • 6. Immutability & Recursion
    • 6.1 Immutability
    • 6.2 Immutability advantages
    • 6.3 The price of immutability
    • 6.4 Immutability and functional programming
    • 6.5 Immutability and recursion
    • 6.6 Challenges
    • 6.7 Key points
    • 6.8 Where to go from here?
  • 7. Functional Data Structures
    • 7.1 Immutable data structure
    • 7.2 Mutators
    • 7.3 Why FList<T> is a persistent data structure
    • 7.4 Challenges
    • 7.5 Key points
    • 7.6 Where to go from here?
  • 8. Composition
    • 8.1 Composition in Kotlin
    • 8.2 Partial application
    • 8.3 Compose functions with side effects
    • 8.4 Compose mutation
    • 8.5 Challenges
    • 8.6 Key points
    • 8.7 Where to go from here?

Section II: Data Types & Typeclasses

Section 2: 5 chapters
  • 9. Data Types
    • 9.1 What is a data type?
    • 9.2 The Optional<T> data type
    • 9.3 The List<T> data type
    • 9.4 What about FList<T>?
    • 9.5 The Either<A, B> data type
    • 9.6 Challenges
    • 9.7 Key points
    • 9.8 Where to go from here?
  • 10. Algebraic Data Types
    • 10.1 What is algebra?
    • 10.2 Data types and multiplication
    • 10.3 Data types and addition
    • 10.4 Putting algebra to work
    • 10.5 Other algebraic properties
    • 10.6 Fun with exponents
    • 10.7 Using algebra with the List type
    • 10.8 Key points
    • 10.9 Where to go from here?
  • 11. Functors
    • 11.1 What is a functor?
    • 11.2 Functors in programming
    • 11.3 Functor laws
    • 11.4 The FList<T> and List<T> functors
    • 11.5 Bifunctors
    • 11.6 Typeclasses
    • 11.7 Key points
    • 11.8 Where to go from here?
  • 12. Monoids & Semigroups
    • 12.1 What is a monoid?
    • 12.2 Property-based testing
    • 12.3 Monoids and foldable types
    • 12.4 Monoids and category theory
    • 12.5 The semigroup typeclass
    • 12.6 Key points
    • 12.7 Where to go from here?
  • 13. Understanding Monads
    • 13.1 The road to monads!
    • 13.2 A pragmatic definition of monad
    • 13.3 Why monads?
    • 13.4 Key points
    • 13.5 Where to go from here?

Section III: Functional Programming in Practice

Section 3: 7 chapters
  • 14. Error Handling With Functional Programming
    • 14.1 Exception handling
    • 14.2 Handling exception strategies
    • 14.3 Applicative functor
    • 14.4 The Kotlin Result<T> data type
    • 14.5 Meet the RayTV app
    • 14.6 Key points
    • 14.7 Where to go from here?
  • 15. Managing State
    • 15.1 The problem
    • 15.2 A practical example
    • 15.3 Key points
    • 15.4 Where to go from here?
  • 16. Handling Side Effects
    • 16.1 From State<S, T> to IO<T>
    • 16.2 The IO<T> monad
    • 16.3 The meaning of IO<T>
    • 16.4 Key points
    • 16.5 Where to go from here?
  • 17. Sequence & Flow
    • 17.1 The Sequence<T> data type
    • 17.2 The Flow<T> data type
    • 17.3 The SharedFlow<T> & StateFlow<T> data types
    • 17.4 Key points
    • 17.5 Where to go from here?
  • 18. Mobius — A Functional Reactive Framework
    • 18.1 Mobius principles and concepts
    • 18.2 The Mobius workflow
    • 18.3 Build your app
    • 18.4 Mobius loop in Android
    • 18.5 Key points
    • 18.6 Where to go from here?
  • 19. Arrow
    • 19.1 Exceptions as side effects
    • 19.2 Arrow optics
    • 19.3 Arrow lenses
    • 19.4 Key points
    • 19.5 Where to go from here?
  • 20. Conclusion

Appendix

Section 4: 13 chapters
  • A. Appendix A: Chapter 1 Exercise Solutions
    • Exercise 1.1
    • Exercise 1.2
  • B. Appendix B: Chapter 2 Exercise & Challenge Solutions
    • Exercise 2.1
    • Exercise 2.2
    • Exercise 2.3
    • Exercise 2.4
    • Exercise 2.5
    • Challenge 1: Functions and sets
    • Challenge 2: Functions and set again
    • Challenge 3: The right domain
  • C. Appendix C: Chapter 3 Exercise & Challenge Solutions
    • Exercise 3.1
    • Exercise 3.2
    • Exercise 3.3
    • Exercise 3.4
    • Exercise 3.5
    • Challenge 1: Pure or impure?
    • Challenge 2: Pure or impure?
    • Challenge 3: Pure or impure?
  • D. Appendix D: Chapter 4 Exercise & Challenge Solutions
    • Exercise 4.1
    • Exercise 4.2
    • Exercise 4.3
    • Exercise 4.4
    • Exercise 4.5
    • Exercise 4.6
    • Challenge 4.1
    • Challenge 4.2
  • E. Appendix E: Chapter 5 Exercise & Challenge Solutions
    • Exercise 5.1
    • Exercise 5.2
    • Exercise 5.3
    • Exercise 5.4
    • Exercise 5.5
    • Challenge 5.1: Mapping is important
    • Challenge 5.2: Prime number filtering
  • F. Appendix F: Chapter 6 Exercise & Challenge Solutions
    • Exercise 6.1
    • Exercise 6.2
    • Exercise 6.3
    • Exercise 6.4
    • Challenge 6.1: Immutability and recursion
    • Challenge 6.2: Tail-recursive Fibonacci
  • G. Appendix G: Chapter 7 Exercise & Challenge Solutions
    • Exercise 7.1
    • Exercise 7.2
    • Exercise 7.3
    • Exercise 7.4
    • Exercise 7.5
    • Exercise 7.6
    • Exercise 7.7
    • Challenge 7.1
    • Challenge 7.2
    • Challenge 7.3
  • H. Appendix H: Chapter 8 Exercise & Challenge Solutions
    • Exercise 8.1
    • Exercise 8.2
    • Exercise 8.3
    • Exercise 8.4
    • Challenge 1: Callable stuff
    • Challenge 2: Parameters or not parameters?
  • I. Appendix I: Chapter 9 Exercise & Challenge Solutions
    • Exercise 9.1
    • Exercise 9.2
    • Exercise 9.3
    • Exercise 9.4
    • Exercise 9.5
    • Challenge 9.1: Filtering
    • Challenge 9.2
    • Challenge 9.3: Average
    • Challenge 9.4: Last
  • J. Appendix J: Chapter 10 Exercise Solutions
    • Exercise 10.1
    • Exercise 10.2
    • Exercise 10.3
  • K. Appendix K: Chapter 12 Exercise Solutions
    • Exercise 12.1
    • Exercise 12.2
    • Exercise 12.3
    • Exercise 12.4
    • Exercise 12.5
  • L. Appendix L: Chapter 13 Exercise Solutions
    • Exercise 13.1
    • Exercise 13.2
  • M. Appendix M: Chapter 14 Exercise Solutions
    • Exercise 14.1
    • Exercise 14.2
Home Android & Kotlin Books Functional Programming in Kotlin by Tutorials

iii
Dedications Written by Massimo Carli

“To my family who’s always here for me.”

— Massimo Carli

iv. About the Team ii. Book Source Code & Forums

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.

© 2022 Razeware LLC