https://medium.com/@cscalfani/so-you-want-to-be-a-functional-programmer-part-1-1f15e387e536

# Tag Archives: Functional programming

# Monads – FP’s answer to Immutability

**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)**

# Alejandro Serrano: Category Theory Through Functional Programming

(**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

# Mathematical Functions vs Programming Functions

# Functional Programming with Kotlin

3) Higher–Order Function, Closure

# Higher Order Function

As Tikhon Jelvis explained in his response, functions map sets to sets, and functions themselves form sets. This is the essence of the untyped lambda calculus. Unfortunately, untyped lambda calculus suffers from the Kleene–Rosser paradox (later simplified to Curry’s paradox).

This paradox can be removed by introducing types, as in the typed lambda calculus. Simple types are equivalent to sets, but in order to pass a function as an argument to another function (or return one), we have to give this function a type. To really understand what a function type is, you need to look into category theory.

The categorical model for the typed lambda calculus is a category in which objects are types and morphism are functions. So if you want to have higher order functions, you have to be able to represent morphisms as objects — in other words, create a type for functions. This is possible only if the category is cartesian closed. In such a category you can define product types and exponential types. The latter correspond to function types.

So that’s a mathematical explanation for higher order.

# You should learn Functional Programming in 2017

WhatsApp is written in Erlang – a Functional Programming Language. It supports 900 million users worldwide with only 50 programmers.