Functional Swift: Updated for Swift 4
Book information
Description
This book will teach you how to use Swift to apply functional programming techniques to your iOS or OS X projects. These techniques complement object-oriented programming that most Objective-C developers will already be familiar with, providing you with a valuable new tool in your developer's toolbox. We will start by taking a look at Swift's new language features, such as higher-order functions, generics, optionals, enumerations, and pattern matching. Mastering these new features will enable you to write functional code effectively. After that, we will provide several examples of how to use functional programming patterns to solve real-world problems. These examples include a compositional and type-safe API around Core Image, a library for diagrams built on Core Graphics, and a small spreadsheet application built from scratch. Functional Swift Introduction Thinking Functionally Example: Battleship First-Class Functions Type-Driven Development Notes Case Study: Wrapping Core Image The Filter Type Theoretical Background: Currying Discussion Map, Filter, Reduce Introducing Generics Filter Reduce Putting It All Together Generics vs. the Any Type Notes Optionals Case Study: Dictionaries Working with Optionals Why Optionals? Case Study: QuickCheck Building QuickCheck Making Values Smaller The Value of Immutability Variables and References Value Types vs. Reference Types Discussion Enumerations Introducing Enumerations Associated Values Adding Generics Swift Errors Optionals Revisited The Algebra of Data Types Why Use Enumerations? Purely Functional Data Structures Binary Search Trees Autocompletion Using Tries Discussion Case Study: Diagrams Drawing Squares and Circles The Core Data Structures Discussion Iterators and Sequences Iterators Sequences Case Study: Traversing a Binary Tree Case Study: Better Shrinking in QuickCheck Case Study: Parser Combinators The Parser Type Combining Parsers Parsing Arithmetic Expressions A Swifty Alternative for the Parser Type Case Study: Building a Spreadsheet Application Parsing Evaluation User Interface Functors, Applicative Functors, and Monads Functors Applicative Functors The M-Word Discussion Conclusion Further Reading Closure Bibliography
Similar books
Thinking in SwiftUI
2020 · PDF
Advanced Swift Updated for Swift 5
2019 · PDF
Core Data - objc.io
2016 · PDF
Advanced Swift - objc.io
2017 · PDF
Core Data - objc.io
2016 · PDF
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF