**Key Point**:

Haskell & any FP compiler don’t check the Category Theory proof if your codes (eg. fmap) follow Functor’s Laws (eg. Preserve structure, identity) or Monad’s Laws !

**Key Point**:

Haskell & any FP compiler don’t check the Category Theory proof if your codes (eg. fmap) follow Functor’s Laws (eg. Preserve structure, identity) or Monad’s Laws !

Advertisements

Category Theory can be approved from 2 directions: 1) Pure Math, 2) IT Functional Programming (FP) .

Dr. Eugenia Cheng doesn’t know 2), she comes from 1).

The second video (below) approaches Category Theory from 2): Scala – FP language.

**Key Points:**

1. **BCCC** (Bi-Cartesian Closed Category): **PRODUCT** (tuple) , **SUM** (either) , **EXPONENTIAL** (function)

2. UNIT, ZERO, Absurd

3. Equivalences

As software becomes more complicated for high-speed trains, driverless cars, missile weapons. .. and AI deeplearning algorithm, we can’t depend our life safety on the programmers who don’t understand the advanced maths behind these algorithms.

The Advanced Math is the Category Theory – the most advanced math foundation above “Set Theory” since WW2. Functional Programming is based on Category Theory with mathematical functions – always output correctly with no “side-effects”.

https://www.extremetech.com/computing/259977-software-increasingly-complex-thats-dangerous

*There exists in almost all Universities a clear division between pure and applied mathematics. A friendly (and sometimes not so friendly) rivalry exists between both sides of the divide, with separate conferences, separate journals and in many cases even a whole separate language. ***Category Theory*** was seen as such an abstract area of research that even pure mathematicians started to refer to it as “**abstract nonsense**“, and until the mid 1980’s almost all category theorists occupied a place hidden somewhere up above the ‘cloud level’ in the highest reaches of the peaks that defined “pure” maths.*

…

By the mid 1990’s and then by the turn of the millenium, a whole world of computer programmers were learning basic category theory as part of their induction into functional programming. The best known product of these efforts is the Haskell language, but even in the past 7 or 8 yrs, workshops on category theory for computer programmers of all types have flourished and proliferated. It is almost as if there are two separate communities masquerading as one – **mathematical category theory and computer programming category theory** – and never the twain would meet. Or so it seemed, until now.

https://www.linkedin.com/pulse/category-theory-classic-dichotomy-purest-pure-may-also-khan-ksg/

**Introduction**:

- The curse of Immutability in Functional Programming – no “Looping” (recursion ok), no Date, no Random, …no I/O …
- Monad is the Savior of “No Side Effect: IO Monads

**Promise of Monads (A)**

**Promise of Monads (B)**

(**Part 1/3) – λC 2017**

What is Category ?

Objects

Morphism (Arrows )

Rule1: Associative

Rule 2: Identity

A <– C –> B

Product of Categories : A x B

Unique

Sum of Categories: A + B

Unique

(Either a b)

**Co-Product**

Reverse all arrows.

Unique

**Functor F: C-> D**

Mapping of all objects (A, B) in categories C,D

Mapping of arrows f

f : A -> B

Ff : FA -> FB (preservation)

F Id = Id

F (f。g) = Ff。Fg

Example:

Constant C -> F

FC = k

Ff = Id

**Arrow Functor F: C -> D**

For any object A in C,

F A = D -> A

(Functional Type is also Type)

Functors compose !

**Category of categories:**

Objects: categories

Arrows : Functors

Haskell Category (Hask) is always Endo-Functor, ie Category Hask to itself.

Mapping of arrows.

Mapping of Objects = predefined

(Part 2/3) – λC 2017

(part 3/3) – λC 2017