Learning Functional Programming: Managing Code Complexity by Thinking Functionally

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Learn how to think and write code like a functional programmer. With this practical guide, software developers familiar with object-oriented programming will dive into the core concepts of functional programming and learn how to use both functional and OOP features together on large or complex software projects. Author Jack Widman uses samples from Java, Python, C#, Scala, and JavaScript to help you gain a new perspective and a set of tools for managing the complexity in your problem domain. You'll be able to write code that's simpler, reusable, easier to test and modify, and more consistently correct. This book also shows you how to use patterns from category theory to help bridge the gap between OOP and functional programming. • Learn functional programming fundamentals and explore the way functional programmers approach problems • Understand how FP differs from object-oriented and imperative programming • Use a set of practical, applicable design patterns that model reality in a functional way • Learn how to incorporate FP and OOP features into software projects • Apply functional design patterns appropriately and use them to write correct, robust, and easily modifiable code

Author(s): Jack Widman
Edition: 1
Publisher: O'Reilly Media
Year: 2022

Language: English
Commentary: Publisher's PDF
Pages: 135
City: Sebastopol, CA
Tags: Python; Java; JavaScript; C#; Functional Programming; Scala; Lambda Functions; Laziness; Monads; Akka; Category Theory; Comprehensions; Streams; Immutability; Referential Transparency; Higher Order Functions; Lazy Evaluation; Functional Data Structures

Cover
Copyright
Table of Contents
Preface
Who Should Use This Book?
How The Book Is Organized
Conventions Used in This Book
O’Reilly Online Learning
How to Contact Us
Chapter 1. What Is Functional Programming?
Immutability
Referential Transparency
Higher Order Functions
Lazy Evaluation
Thinking Like a Functional Programmer
The Benefits of FP
FP Can Improve Productivity
FP Is Fun!
Scala
Conclusion
Chapter 2. Mathematical Preliminaries
Set Theory
Functions
Kinds of Functions
Computer Science Fundamentals
Anonymous Functions
Functions as First Class Objects
Conclusion
Chapter 3. Category Theory and Patterns
Category Theory–Based Patterns
A Brief History
Objects and Morphisms
An Example of a Category
The Category Scal
Functors
Programming Language Formulation of a Functor
The Patterns
The Functor Pattern
Monoids
Natural Transformations
Monads
Conclusion
Chapter 4. Functional Data Structures
The Option Data Structure
The Try Data Structure
The Either Data Structure
Higher Order Functions
Monads in for Comprehensions in Scala
Traditional Data Structures
Immutability and History
Laziness
Conclusion
Chapter 5. More on Immutability
Mutable and Immutable Variables
Recursion
A Linked List Example
Tail Recursion
More Examples of the Power of fold in Scala
A Connection Between fold and Monoids
More with Higher Order Functions
From map to flatMap
Conclusion
Chapter 6. Questions of Concurrency
Streams
Akka Streams
Source
Flow
Sink
More on Streams
FS2: Functional Streams for Scala
Conclusion
Chapter 7. Where to from Here?
Taking the Pure Route
The IO Monad
Taking the Middle Route
JVM Languages
.NET Languages
Type Classes
Conclusion
Appendix. Scala
Assumptions
Overview
var and val
Classes and Objects
Functions
Functions that Return Functions
Case Classes
Declaring Functions
Currying
Anonymous Functions
Higher Order Functions
Pattern Matching
Traits
Distinguishing Abstract Classes and Traits
Lazy Evaluation
Type Parameters
The Option Type
Future
Some Key Higher Order Functions
Some Other Important Higher Order Functions
Conclusion
Index
About the Author
Colophon