Swift Functional Programming - Second Edition

Bring the power of functional programming to Swift to develop clean, smart, scalable and reliable applications.
Preview in Mapt

Swift Functional Programming - Second Edition

Dr. Fatih Nayebi

Bring the power of functional programming to Swift to develop clean, smart, scalable and reliable applications.
Mapt Subscription
FREE
$29.99/m after trial
eBook
$25.20
RRP $35.99
Save 29%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$25.20
$44.99
$29.99p/m after trial
RRP $35.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Swift Functional Programming - Second Edition Book Cover
Swift Functional Programming - Second Edition
$ 35.99
$ 25.20
Swift 3 Object-Oriented Programming - Second Edition Book Cover
Swift 3 Object-Oriented Programming - Second Edition
$ 31.99
$ 22.40
Buy 2 for $35.00
Save $32.98
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

Book Details

ISBN 139781787284500
Paperback316 pages

Book Description

Swift is a multi-paradigm programming language enabling you to tackle different problems in various ways. Understanding each paradigm and knowing when and how to utilize and combine them can lead to a better code base. Functional programming (FP) is an important paradigm that empowers us with declarative development and makes applications more suitable for testing, as well as performant and elegant. This book aims to simplify the FP paradigms, making them easily understandable and usable, by showing you how to solve many of your day-to-day development problems using Swift FP.

It starts with the basics of FP, and you will go through all the core concepts of Swift and the building blocks of FP. You will also go through important aspects, such as function composition and currying, custom operator definition, monads, functors, applicative functors,memoization, lenses, algebraic data types, type erasure, functional data structures, functional reactive programming (FRP), and protocol-oriented programming(POP). You will then learn to combine those techniques to develop a fully functional iOS application from scratch

Table of Contents

Chapter 1: Getting Started with Functional Programming in Swift
Why functional programming matters
What is FP?
The Swift programming language
Summary
Chapter 2: Functions and Closures
What is a function?
Syntax
Pure functions
Function types
First-class functions
Higher-order functions
Function composition
Closures
Function currying
Recursion
Memoization
Summary
Chapter 3: Types and Type Casting
Kinds of types
Value versus reference types
Equality versus identity
Equatable and Comparable
Type checking and casting
Summary
Chapter 4: Enumerations and Pattern Matching
Defining enumerations
Algebraic data types
Pattern matching
Summary
Chapter 5: Generics and Associated Type Protocols
What are Generics and what kind of problems do they solve?
Type constraints
Generic data structures
Associated type protocols
Type erasure
Extending Generic types
Subclassing Generic classes
Generics manifesto
Summary
Chapter 6: Map, Filter, and Reduce
Higher-kinded types
The map function
The flatMap method
The filter function
The reduce function
The apply function
The join function
Chaining higher-order functions
The zip function
Practical examples
Summary
Chapter 7: Dealing with Optionals
Optional types
Unwrapping optionals
Guard
Implicitly-unwrapped optionals
Nil-coalescing
Optional chaining
Dealing with Optionals' functionally
Error handling
Summary
Chapter 8: Functional Data Structures
Semigroups
Monoids
Trees
Lists
Stacks
Lazy lists
Summary
Chapter 9: Importance of Immutability
Immutability
Immutable variables
Reference types versus value types
Benefits of immutability
Cases for mutability
An example
Copy constructors and lenses
Summary
Chapter 10: Best of Both Worlds and Combining FP Paradigms with OOP
OOP paradigms
OOP design principles
POP
Functional reactive programming
Mixing OOP and FP
Summary
Chapter 11: Case Study - Developing an iOS Application with FP and OOP Paradigms
Requirements
High-level design
Backend development
iOS application development
Summary

What You Will Learn

  • Understand what functional programming is and why it matters
  • Understand custom operators, function composition, currying, recursion, and memoization
  • Explore algebraic data types, pattern matching, generics, associated type protocols, and type erasure
  • Get acquainted with higher-kinded types and higher-order functions using practical examples
  • Get familiar with functional and non-functional ways to deal with optionals
  • Make use of functional data structures such as semigroup, monoid, binary search tree, linked list, stack, and lazy list
  • Understand the importance of immutability, copy constructors, and lenses
  • Develop a backend API with Vapor
  • Create an iOS app by combining FP, OOP, FRP, and POP paradigms

Authors

Table of Contents

Chapter 1: Getting Started with Functional Programming in Swift
Why functional programming matters
What is FP?
The Swift programming language
Summary
Chapter 2: Functions and Closures
What is a function?
Syntax
Pure functions
Function types
First-class functions
Higher-order functions
Function composition
Closures
Function currying
Recursion
Memoization
Summary
Chapter 3: Types and Type Casting
Kinds of types
Value versus reference types
Equality versus identity
Equatable and Comparable
Type checking and casting
Summary
Chapter 4: Enumerations and Pattern Matching
Defining enumerations
Algebraic data types
Pattern matching
Summary
Chapter 5: Generics and Associated Type Protocols
What are Generics and what kind of problems do they solve?
Type constraints
Generic data structures
Associated type protocols
Type erasure
Extending Generic types
Subclassing Generic classes
Generics manifesto
Summary
Chapter 6: Map, Filter, and Reduce
Higher-kinded types
The map function
The flatMap method
The filter function
The reduce function
The apply function
The join function
Chaining higher-order functions
The zip function
Practical examples
Summary
Chapter 7: Dealing with Optionals
Optional types
Unwrapping optionals
Guard
Implicitly-unwrapped optionals
Nil-coalescing
Optional chaining
Dealing with Optionals' functionally
Error handling
Summary
Chapter 8: Functional Data Structures
Semigroups
Monoids
Trees
Lists
Stacks
Lazy lists
Summary
Chapter 9: Importance of Immutability
Immutability
Immutable variables
Reference types versus value types
Benefits of immutability
Cases for mutability
An example
Copy constructors and lenses
Summary
Chapter 10: Best of Both Worlds and Combining FP Paradigms with OOP
OOP paradigms
OOP design principles
POP
Functional reactive programming
Mixing OOP and FP
Summary
Chapter 11: Case Study - Developing an iOS Application with FP and OOP Paradigms
Requirements
High-level design
Backend development
iOS application development
Summary

Book Details

ISBN 139781787284500
Paperback316 pages
Read More

Read More Reviews

Recommended for You

Swift 3 Object-Oriented Programming - Second Edition Book Cover
Swift 3 Object-Oriented Programming - Second Edition
$ 31.99
$ 22.40
Swift 3 Protocol-Oriented Programming - Second Edition Book Cover
Swift 3 Protocol-Oriented Programming - Second Edition
$ 31.99
$ 22.40
Swift 3 Game Development - Second Edition Book Cover
Swift 3 Game Development - Second Edition
$ 31.99
$ 22.40
Learning Swift - Second Edition Book Cover
Learning Swift - Second Edition
$ 31.99
$ 22.40
Swift Essentials - Second Edition Book Cover
Swift Essentials - Second Edition
$ 27.99
$ 19.60
Swift 4 Protocol-Oriented Programming - Third Edition Book Cover
Swift 4 Protocol-Oriented Programming - Third Edition
$ 31.99
$ 22.40