Nick Arner

Notes from Functional Swift

Posted at — Nov 26, 2022

These are my notes from objc.io’s Functional Swift book. For a recent proejct, I’ve had to dive into a codebase that heavily makes use of functional programming in Swift; this book was helpful in getting a basic understanding of functional programming concepts in the world of Swift and iOS.


Characteristics of Functional Programming:

Functions are first-class values

Generics

Map / Filter / Reduce

Any vs Genertics

Value and Reference Types

Structs

Mutating Structs

extension Point Struct {
	mutating func fooBar() {
		x = 0
		y = 1
	}
}

 

Types

Types are isomorphic if we can convert between them w/o losing any information:

f: (A) -> B
g: (B) -> A

DSL’s (Domain Specific Languages)

Iterators

​ separeate generation of data from usage

Sequence

Lazy Sequences

Parser Combinators