What Makes Functional and Object-oriented Programming Equal


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.

1. Function:

2. Closure (variable binding)

3. Currying

4. Function Composition


A Programmer’s Regret: Neglecting Math at University – Adenoid Adventures

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


A Functional Programmer’s Guide to Homotopy Type Theory (HoTT)

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:

  1. First go through the whole video,
  2. Don’t understand? view other related simpler videos.
  3. Repeat 1.

Prerequisite knowledge:

  1. Homotopy
  2. Type Theory
  3. Homotopy Type Theory
  4. Bijection = Isomorphism
  5. Functional Programming in Category Theory Concept: Monad & Applicative

Two Key Takeaway Points:

  1. In the Homotopy “Space” : Programs are points in the space, Paths are Types.
  2. “Univalence Axiom” : Paths Induce Bijection, vice versa.

Knowing Monads Through The Category Theory


While Mathematicians like to talk non-sensical abstract idea, Informaticians want to know how to apply the idea concretely:

Mathematical Parlance:

Monad = Monoid +Endofunctor

Monoid = Identity + Associative

Endo-functor = functor between 2 same categories

IT Parlance:

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.[2][3]

Exploring Monads in Scala Collections