This time Alexander Voronov (@aleks_voronov), iOS Developer at Stanfy talked about Functional Programming 101 with Swift
Key points:
- Why do we need Functional Programming?
- The power of Swift
- Functors, Applicatives and Monads
- Pipes & Railways
- Functional Swift in real life
Links Mentioned:
- Functors, Applicatives and Monads in Pictures: http://adit.io/posts/2013-04-17-funct...
- Railway Oriented Programming: http://fsharpforfunandprofit.com/post...
- Functional Programming in Swift (Objc.io): http://www.objc.io/books/fpinswift/
- Moya: https://github.com/Moya/Moya
- Argo: https://github.com/thoughtbot/Argo
- Swiftz: https://github.com/typelift/Swiftz
- RxSwift: https://github.com/ReactiveX/RxSwift
- ReactiveCocoa-3.0: https://github.com/ReactiveCocoa/Reac...
- Haskell: https://www.haskell.org
- F#: http://fsharp.org
- Erlang: http://www.erlang.org
- Elm: http://elm-lang.org
Watch video from the presentation (rus): https://youtu.be/w6zyGylS4Wk
Join our MadCode group on FB(rus): https://www.facebook.com/MadCodeMeetup/
Find more videos from MadCode Meetups (rus): https://www.youtube.com/playlist?list=PLrplqd3YJvBvUygFkx4Xvx1p3zyiCgB9Q
29. Optional Chaining
struct Dog { var name: String }
struct Person { var dog: Dog? }
let dog = Dog(name: "Dodge")
let person = Person(dog: dog)
let dogName = person.dog?.name
30. Optional Chaining
struct Dog { var name: String }
struct Person { var dog: Dog? }
let dog = Dog(name: "Dodge")
let person = Person(dog: dog)
let dogName = person.dog?.name
Optional Chaining
63. Left Identity Law
let f = { Optional($0 + 1) }
let a = 1
let x = Optional(a) >>- f
let y = f(a)
x == y
64. Right Identity Law
func create<T>(value: T) -> Optional<T> {
return Optional(value)
}
let x = Optional(1) >>- create
let y = Optional(1)
x == y
65. Associativity Law
let double = { Optional(2 * $0) }
let triple = { Optional(3 * $0) }
let x = Optional(1) >>- double >>- triple
let y = Optional(1) >>- { double($0) >>- triple }
let z = { Optional(1) >>- double }() >>- triple
x == y
y == z