Comparison of 4 Functional Programming (FP : F#, Lisp/Clojure Haskell, Scala,… ) concepts in Object-Oriented (OO: C#, C++, Java,… ) :
[Not covered here] : There are other FP techniques lacking in OO: Functor (FoldMap), Monad, etc.
2. Closure (variable binding)
4. Function Composition
Advanced Programming needs Advanced Math: eg.
Video Game Animation: Verlet Integration
AI: Stats, Probability, Calculus, Linear Algebra
Search Engine : PageRank: Linear Algebra
Abstraction in Program “Polymorphism” : Monoid, Category, Functor, Monad
Program “Proof” : Propositions as Types, HoTT
Abstraction: Monoid, Category
Functional Programming has the following key styles:
1) Lambda function:
2) Map, Filter, Reduce
Since April 2019 until I re-visit this Youtube video on 12 August 2019, I can now totally understand his speech after a pause of 4 months by viewing other related Youtube (below prerequisite) videos on Category Theory, Type Theory, Homotopy Type Theory.
That is the technique of self-study:
- First go through the whole video,
- Don’t understand? view other related simpler videos.
- Repeat 1.
- Type Theory
- Homotopy Type Theory
- Bijection = Isomorphism
- Functional Programming in Category Theory Concept: Monad & Applicative
Two Key Takeaway Points:
- In the Homotopy “Space” : Programs are points in the space, Paths are Types.
- “Univalence Axiom” : Paths Induce Bijection, vice versa.
While Mathematicians like to talk non-sensical abstract idea, Informaticians want to know how to apply the idea concretely:
Monad = Monoid +Endofunctor
Monoid = Identity + Associative
Endo-functor = functor between 2 same categories
Monad is a ‘function’ to wrap the ‘side effects’ (exception errors, I/O,… ) so that function composition in ‘pipeline‘ chained operation sequence is still possible in pure FP (Functional Programming, which forbids side-effects).
Some common Monads: ‘Maybe’, ‘List’, ‘Reader’…
This allows monads to simplify a wide range of problems, like handling potential undefined values (with the
Maybe monad), or keeping values within a flexible, well-formed list (using the
List monad). With a monad, a programmer can turn a complicated sequence of functions into a succinct pipeline that abstracts away additional data management, control flow, or side-effects.
Exploring Monads in Scala Collections