A Functional Programming Kickstart


Introducing Functional Programming Fundamentals in Swift

Functional Programming Kickstart

There's nothing natural about Functional Programming.

It's awkward, it feels funny, there's something not right about it ... and then one day you start to see the world differently and you can't remember what was so difficult.

This hand-on, fast-moving kickstart will provide you with a new set of skills that you can add to - not replace - your current favorite programming techniques.

Updated for Xcode 12 and Swift 5.3 and tested on Apple Silicon.

Contents


Chapter 1: Magic

The Trick

A Card

The Mutating Card

The Non-Mutating Card

Changing a Card

Destroy and Restore a Card

The Deck

Performing the Trick

Road Map

Credits, Bio, and Version History

Chapter 2: Functions aren't special

Pure Functions

Trick Deck

A Simple Label

A Simple Button

Mutating State

Displaying Cards

Mutable Middle

One for Fun

Chapter 3: Higher-Order Functions

Lines

Making Functions

Closures

Making Closures

Consuming Closures

Generics

Call as Function

Custom Operators

Flexible Trick

Chapter 4: Arrays

Filter

Sorted

Map

CompactMap

FlatMap

Reduce

Zip

Playing with a Full Deck

Chapter 5: Map

The Magic of Map

One at a Time

Zero or One

Optionals

Result

Writer

The Map Pattern

The Magic of Map Revealed

Chapter 6: FlatMap

The Magic of FlatMap

Writer

Shiny Trunk

Result

Optionals

The shape of map and flatMap

Just

Monoids

Chapter 7: Apply

The Magic of Apply

Arrays

The Interchange Law

Currying

Optionals

Between Functor and Monad

Result

Validated

Chapter 8: Deeper Magic

String Function

Reader

The Reader Monad

Parsers

State

The State Monad

So...

Related


Training from Dim Sum Thinking

Screenshots


screenshot 1

screenshot 2

screenshot 3