# Category Archives: Functional Programmimg

# Programming A Scripting Language in C++17

# Category Theory is in our minds? Bartosz Milewski weighs in. – CoRecursive Podcast

# Functional C++ for Fun and Profit

# Functional Programming in C++

# Programming with Math (Exploring Type Theory)

If you are inventing a new language, start to study Type Theory.

These 3 are the same thing:

Logic = Category = Type

…

Unfortunately Milewski’s presentation was cut short due to time constraint, he only presented the first few “Type” functions:

- Unit,
- Product,
- Sum,
- Exponential,…

(these are from Category Theory refound in Type Theory).

…

# Quora: What is an ALGEBRA structure

What is an algebra? by Tikhon Jelvis https://www.quora.com/What-is-an-algebra/answer/Tikhon-Jelvis?ch=3&share=2dd8711d&srid=oZzP

“Basically, an algebra is just an algebraic structure. It’s some set A along with some number of functions closed over the set. It’s a generalization over the structures we normally study: a group is an algebra, a ring is an algebra, a lattice is an algebra… etc.

Algebras have different “signatures” which specify the functions it has. For example, a group is an algebra that has an identity element, a function of one argument and a function of two arguments.

That is, a group with a carrier set A is just a tuple:

⟨A, 0:A, −:A→A, +:A×A→A⟩

For uniformity, we can write all of these as functions in the form An→A, where n is the “arity” of a function—the number of arguments it has. The identity element is a function A0→A, which just identifies a single element from A. Thus, we can talk about the signature of an algebra as the arities of its functions.

A group would be (0, 1, 2) while a ring would be (0, 0, 1, 2, 2).

Generally, the functions of an algebra have to be associative. Sometimes, we also look at other laws—for example, we might want to study algebras with commutative operations like Abelian groups.

So the intuition for an algebra in general is that it’s any structure like a group, a ring or whatever else we like. As the name “structure” implies, these additional operations on a set expose the internal structure of its elements:

a group describes symmetries, a lattice describes a partial order and so on.

The study of algebras, then, can be thought of as the study of “structured sets” in general.”

# Kotlin FP: Interface vs Extension

When more **specific behavior** needed, use “interface”.

eg. Interface Vehicle: drive()

-> car.drive ();

-> motorcycle.drive ();

If it is a common **general behavior**, use **extension**.

https://blog.oozou.com/interface-in-kotlin-and-when-to-use-it-5d32caab19be

# ScalaFP: the Reasons Behind Monads

Why Monad:

1. Functional Programming:

“pure” function = no side effects

2. All applications without side effects are useless!

3. Monad wraps side-effect as if it is “pure” for FP composition.

https://dzone.com/articles/scalafp-lets-find-the-reasons-behind-monads