<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Juan López</title>
    <description>The latest articles on DEV Community by Juan López (@juaneto).</description>
    <link>https://dev.to/juaneto</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F124142%2F06bf7e43-0a0d-440a-bac2-964359a9cabb.jpg</url>
      <title>DEV Community: Juan López</title>
      <link>https://dev.to/juaneto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/juaneto"/>
    <language>en</language>
    <item>
      <title>RSA: How Maths will protect us while P!=NP</title>
      <dc:creator>Juan López</dc:creator>
      <pubDate>Mon, 31 Dec 2018 09:01:37 +0000</pubDate>
      <link>https://dev.to/juaneto/rsa-how-maths-will-protect-us-while-pnp-koi</link>
      <guid>https://dev.to/juaneto/rsa-how-maths-will-protect-us-while-pnp-koi</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In a previous &lt;a href="https://dev.to/juaneto/knowing-monads-through-the-category-theory-1mea"&gt;post&lt;/a&gt; we talked about how mathematics could help us become better programmers, this time we will talk about how mathematics is the basis of global cybersecurity thanks to &lt;strong&gt;RSA cryptography&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The importance of &lt;strong&gt;cryptography&lt;/strong&gt; has been very large through history. Mainly it has been used by military and governments, being able to keep secrets with the enemies can be the main factor of victory.&lt;/p&gt;

&lt;p&gt;There are many examples and stories about its use in history.&lt;a href="https://en.wikipedia.org/wiki/Caesar_cipher" rel="noopener noreferrer"&gt; Caesar’s cipher&lt;/a&gt;, used by Julius Caesar to hide his military secrets, the famous&lt;a href="https://en.wikipedia.org/wiki/Zimmermann_Telegram" rel="noopener noreferrer"&gt; Zimmermann Telegram&lt;/a&gt; that accelerated the entry of the United States in the First World War, or work of&lt;a href="https://en.wikipedia.org/wiki/Alan_Turing#Cryptanalysis" rel="noopener noreferrer"&gt; Alan Turing&lt;/a&gt;, who worked on decrypting the Nazi codes, particularly those of the Enigma machine which shortened the Second World War about two years (historians estimation). And many more examples…&lt;/p&gt;

&lt;p&gt;Now it is not only used in war conflicts, but also in security conflicts (both personal and corporate) and in the fight for the defense of personal privacy. Phil Zimmermann (creator of&lt;a href="https://en.wikipedia.org/wiki/Pretty_Good_Privacy" rel="noopener noreferrer"&gt; PGP&lt;/a&gt;) summed it up in a statement whose first (and very good) sentence is &lt;em&gt;“It’s personal. It’s private. And it’s no one’s business but yours.”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The main objective of this post is to explain two things: one, how the RSA algorithm works and on what lies his complexity and (two) why mathematics right now supports its security, that is, we will talk about the famous and very important question &lt;strong&gt;P = NP?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Public Key Cryptography
&lt;/h2&gt;

&lt;p&gt;Since cryptography existed up to thousands of years later, the importance of the encryption system lays in the complexity of the algorithm and in the distribution of the key to decrypt it. More and more complex algorithms were built, which required an increasingly complex key, in turn, to be decrypted. But these algorithms always had the same problem. What happens if the key is found? How could you distribute the password without compromising your privacy? In a small part of cases, this caused real logistical problems, for example when distributing the thousands of key books generated by a large army. In the end, the sophistication of the algorithm did not matter, all were vulnerable if the key to decryption was found.&lt;/p&gt;

&lt;p&gt;So the cryptographic community began to focus on the distribution of the keys, and with it began to work theoretically in something that seems contradictory: a system of exchange of keys.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;1976&lt;/strong&gt;, at the historic National Computing Congress, Whitfield Diffie and Monte Hellman presented the&lt;a href="http://www.cs.berkeley.edu/~christos/classics/diffiehellman.pdf" rel="noopener noreferrer"&gt; Diffie-Hellman&lt;/a&gt; algorithm. They came up with a way for two individuals to exchange encrypted messages without having to exchange any key. This method used modular arithmetic as well as the properties of the prime numbers of the operations that imply them.&lt;/p&gt;

&lt;p&gt;Diffie and Hellman proposed the bases that were soon taken and developed in &lt;strong&gt;1977&lt;/strong&gt; by Ronald Rivest, Adi Shamir and Leonard Adleman, who determined that the ideal mathematical function to create an asymmetrical cryptography system with the public key was factorization. This is the origin of the &lt;strong&gt;RSA&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does RSA work?
&lt;/h2&gt;

&lt;p&gt;Recall that the RSA algorithm is asymmetric cryptography, also called &lt;strong&gt;public-key cryptography&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In short, a public-key algorithm works as if each of us had an open box (of which only the owner has the key) so that anyone could enter a message. When someone wants to send us something, he or she enters the message in the box and closes it. Now only the owner can open it. That way, if I want to send a message to Bob, I’ll just have to look for his box, enter the message inside and close his box.&lt;/p&gt;

&lt;p&gt;Later we will explain the functions that are used to encrypt the messages but we will start explaining above, how it works and what the mechanism is.&lt;/p&gt;

&lt;p&gt;We could do it with the classic example of&lt;a href="http://cryptocouple.com/Alice%20and%20Bob%20-%20DuPont%20and%20Cattapan%202017.pdf" rel="noopener noreferrer"&gt; Alice and Bob&lt;/a&gt;, but you can find many examples with these characters and we prefer to do it, because we like it much more, with Star Wars.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encryption&lt;/strong&gt; example with RSA:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Leia records the message explaining to Obi-Wan that the R2D2 unit includes fundamental information for the Rebel Alliance, which should reach Alderaan as soon as possible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leia asks R2D2 to encrypt the message with the public key of Obi-Wan Kenobi.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AC5M00DEGIyBMSgHIPye7oQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AC5M00DEGIyBMSgHIPye7oQ.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Leia sends R2D2 with this message to find Obi-Wan and show it to him.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AiqE3YVlvE39bu-N6w3WDLw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AiqE3YVlvE39bu-N6w3WDLw.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Obi-Wan receives the message, thanks to Luke, and decrypts it with his private key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Obi-Wan can already understand Leia’s message and get down to work with Luke to help the Rebel Alliance.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A2Us6RWnfDml3z5OZLBclgg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A2Us6RWnfDml3z5OZLBclgg.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Digital signature&lt;/strong&gt; example with RSA:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Read the message (same as the previous example).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leia asks R2D2 to digitally message with his private key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leia sends this message with R2D2 to find Obi-Wan and show it to him.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Obi-Wan receives the digitally signed message and verifies that the message is effectively from the princess using Leia’s public key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Obi-Wan can now listen to the message in complete confidence that the person who has recorded it has been read.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the real world, sadly Leia, Obi-Wan, and R2D2 don’t exist :_( , so we can change Leia and Obi-Wan for random people (or anything that needs to send a message) and R2D2 by Internet to give sense to the example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let´s learn RSA´s maths (only for the brave ones)
&lt;/h2&gt;

&lt;p&gt;First of all, if you are not a maths lover or you can´t wait to know more about P=NP? (or you are just tired) jump to the next chapter.&lt;/p&gt;

&lt;p&gt;Let’s start by the beginning. We have to choose two prime numbers that are big … how big? Of the order of 10200. Neither can be very close to each other, let’s say they have to have at least a difference of the order of 1090.&lt;/p&gt;

&lt;p&gt;The number &lt;strong&gt;n = p * q&lt;/strong&gt; is half of our public key! To find the other half we have to do some more operations. First, we find the number φ(n) = (p-1) (q-1) what is called&lt;a href="https://en.wikipedia.org/wiki/Euler%27s_totient_function" rel="noopener noreferrer"&gt; fi of Euler&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now we have to find a number such that the greatest common divisor of φ(n) and that number is 1, ie, be &lt;strong&gt;coprime&lt;/strong&gt;. There are many possibilities, there are even people who prefer to always take the same: 216 + 1 = 65537. No matter what you choose, the important thing is to be coprime (we’ll see why). We call this number e and it is the other half of our public key. That is, the public key is: &lt;strong&gt;(n, e)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And the private key? The private key &lt;strong&gt;d&lt;/strong&gt; is the&lt;a href="https://en.wikipedia.org/wiki/Modular_multiplicative_inverse" rel="noopener noreferrer"&gt; modular inverse&lt;/a&gt; of e in the module φ(n). This inverse exists and is &lt;strong&gt;unique&lt;/strong&gt; because &lt;strong&gt;φ(n) and e are coprimes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now, let’s say that we have published somewhere our public key (n,e) = (46927,39423) and now a friend wants to send us the message m = “YES”. How would he encrypt it?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The first thing is to convert the letters to a number, that is, in the 26-letter alphabet put m in base 26. In our example: YES = (24,4,18) → x = 24 * 262 + 4 * 26 + 18 * 260 = 16346.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We now use the formula y=xe(mod n). That is, we raise x to e and find the remainder of that number by dividing by n. In our example: y = 1634639423 (mod 46927) then y = 21166.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We only have to put that number again on base 26: c = (y)2626. In our example: 21166 = 1 * 263+ 5 * 262 + 8 * 261 + 2 = (1582) 26 → BFIC.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So he send us the text c = “BFIC” … ok … how do we decrypt it? That is, with the private key, simply by doing: m = cd (mod n).&lt;/p&gt;

&lt;p&gt;Observations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If we public &lt;strong&gt;d&lt;/strong&gt; then anyone can decrypt the message.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we public &lt;strong&gt;p&lt;/strong&gt; or &lt;strong&gt;q&lt;/strong&gt; then anyone could calculate &lt;strong&gt;φ(n)&lt;/strong&gt; so could calculate &lt;strong&gt;d&lt;/strong&gt;. So knowing &lt;strong&gt;φ(n)&lt;/strong&gt; is the same as knowing &lt;strong&gt;p&lt;/strong&gt; and &lt;strong&gt;q&lt;/strong&gt;. ¹&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We could decrypt the message without stealing anything, “only” finding p and q by factorizing n. This is the main point of the next section.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  P=NP?
&lt;/h2&gt;

&lt;p&gt;This is the question that is on everyone’s lips. But… why?&lt;/p&gt;

&lt;p&gt;Broadly speaking, if this equality were met, world security would be compromised because many algorithms (also the RSA) would be able to be solved in reasonably small times.&lt;/p&gt;

&lt;p&gt;But we are not going to stay in these few lines, we are going to explain with a little more depth what this equation??? means. Go for it.&lt;/p&gt;

&lt;p&gt;The first thing we need to know is that we are focusing on &lt;strong&gt;decision problems&lt;/strong&gt;. These problems are those where the possible answers are “&lt;strong&gt;yes&lt;/strong&gt;” or “&lt;strong&gt;no&lt;/strong&gt;“.&lt;/p&gt;

&lt;p&gt;We can classify these problems into classes of complexity, two of these classes are in which we are going to focus: &lt;strong&gt;P&lt;/strong&gt; and &lt;strong&gt;NP&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;P class&lt;/strong&gt; compose those problems that are &lt;strong&gt;solved&lt;/strong&gt; &lt;strong&gt;in a&lt;/strong&gt; &lt;strong&gt;polynomial time&lt;/strong&gt; ². The variable that defines the time that will take the algorithm is the input data. An example of an algorithm: Game of Life — Given an initial configuration of&lt;a href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" rel="noopener noreferrer"&gt; Conway’s Game of Life&lt;/a&gt;, a particular cell, and a time T (in unary), is that cell alive after T steps? ³&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;NP class&lt;/strong&gt; is composed of those problems in which the solution can be &lt;strong&gt;checked in a polynomial time&lt;/strong&gt;. Remark that is the verification, not the resolution of the problem that is solved in polynomial time. We already have a lot of NP class, all the problems of class P! This is because the class &lt;strong&gt;P is contained in the class NP&lt;/strong&gt; because if we delay in solving them in a polynomial time will also take a polynomial time to verify them.&lt;/p&gt;

&lt;p&gt;Let’s think about the RSA. We know that the factorization of numbers takes an &lt;strong&gt;exponential time&lt;/strong&gt;but verification can be done in a polynomial time (simply checking if the division between each of the primes in which it is factored has zero rest). There are other examples of NP problems such as the traveler problem (belongs to the NP-complete class). These problems are NP, but … Are they in class P? If they were, we would have a big problem.&lt;/p&gt;

&lt;p&gt;From here comes our initial question, will be &lt;strong&gt;P = NP?&lt;/strong&gt; Are the two classes really the same class? Can we solve NP problems in a polynomial time?&lt;/p&gt;

&lt;p&gt;If we finally proved that these problems are in class P (and therefore P = NP), many things would change. One way to prove this would be to see that a NP-complete class problem belongs to class P, so all NP problems would be P … but that’s another story.&lt;/p&gt;

&lt;p&gt;On the one hand we could solve these problems in a much smaller time, but on the other hand, this would mean that global security would be compromised since algorithms like the RSA would not be effective, and we would have to look for other ways to protect ourselves.&lt;/p&gt;

&lt;p&gt;With quantum computation, these algorithms will no longer make sense since, for example, the &lt;a href="https://en.wikipedia.org/wiki/Shor%27s_algorithm" rel="noopener noreferrer"&gt;Shor algorithm &lt;/a&gt;4 can break RSA in polynomial time. But in the meantime (it seems that quantum computing is not nearly as close as we thought a few years ago), we are safe. And when we are not &lt;strong&gt;mathematics&lt;/strong&gt; will give us another solution to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; ϕ(N) = (p − 1)(q − 1) = pq − p − q + 1 = N − p − q + 1 so p + q = N + 1 − ϕ(N). As we know that pq = N, we have the sum and the product of numbers p and q (you can solve the equation by yourself).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; A polynomial is a sum of terms of type &lt;strong&gt;k * xn&lt;/strong&gt; where &lt;strong&gt;n &amp;gt; = 0&lt;/strong&gt;. For example 3x3 + 5x2. An example of a non-polynomial would be 1/x or 2x.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; P-complete page in Wikipedia:&lt;a href="https://en.wikipedia.org/wiki/P-complete" rel="noopener noreferrer"&gt; https://en.wikipedia.org/wiki/P-complete&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; With the quantum algorithm of Shor the factorial decomposition would take O((log N)3) instead of O((log N)k). From exponential to polynomial.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;This post originally appeared on &lt;a href="http://www.datio.com/security/rsa-how-maths-will-protect-us-while-pnp/" rel="noopener noreferrer"&gt;Datio’s Blog&lt;/a&gt; on July 31, 2017.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rsa</category>
      <category>cryptography</category>
      <category>maths</category>
      <category>security</category>
    </item>
    <item>
      <title>Knowing Monads Through The Category Theory</title>
      <dc:creator>Juan López</dc:creator>
      <pubDate>Wed, 26 Dec 2018 22:17:18 +0000</pubDate>
      <link>https://dev.to/juaneto/knowing-monads-through-the-category-theory-1mea</link>
      <guid>https://dev.to/juaneto/knowing-monads-through-the-category-theory-1mea</guid>
      <description>&lt;p&gt;We all know that programming is based on math, what is perhaps not so clear is that knowing more math is going to help us become better developers. And although in all types of programming, math is fundamental, it is even more so in functional programming.&lt;/p&gt;

&lt;p&gt;A very widespread concept which I’m sure you have heard lately is the &lt;strong&gt;monad&lt;/strong&gt;. It is a mathematical concept of the &lt;strong&gt;category theory&lt;/strong&gt; applied later in functional programming.&lt;/p&gt;

&lt;p&gt;I first heard the term when I started programming in Scala. After much searching on the Internet, I only found articles explained by and for mathematicians or articles that talked about programming and not math. On the other hand, some abuse of language is done to refer to things that are not monads as such. So we will try to talk here, without losing the mathematical rigor, about what the monads are, and then how and why they will help us become &lt;strong&gt;better developers&lt;/strong&gt;. Although they are very abstract and complex terms we will try to do it all in a simple way.&lt;/p&gt;

&lt;p&gt;In order to understand the monads, we must first learn about two concepts, categories and functors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Categories
&lt;/h2&gt;

&lt;p&gt;Let’s start with an example:&lt;/p&gt;

&lt;p&gt;Imagine that we have obtained the following map of the Middle Earth of the &lt;strong&gt;Lord of the Rings&lt;/strong&gt;. &lt;strong&gt;Elves&lt;/strong&gt; have made it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcj4w8mzmnhccvp7xirhy.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcj4w8mzmnhccvp7xirhy.jpeg" width="800" height="621"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What do we see on this map?&lt;br&gt;
The first thing we see is a few towns. In addition, we have roads that connect each of the towns, as well as themselves (identity). These are one way or one way back. Also, as seen on the map, you cannot reach every town (Who would want to go to Mordor? Oh, that’s right… hobbits…). On the other hand, it seems clear that if Frodo wants to go from The Shire to Erebor, he can go first through Rivendell or he can go directly to Erebor.&lt;/p&gt;

&lt;p&gt;This is a &lt;strong&gt;category&lt;/strong&gt;. Mathematically speaking, it has two components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The first, a set of sets (the set of towns on Middle Earth)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second, a type of functions/arrows that are called morphisms (the roads that connect the towns). In addition, we can compose the morphisms (as in the previous Frodo example) and this composition is such that any morphism composed with the &lt;strong&gt;identity&lt;/strong&gt; is equal to morphism¹ and such that the composition is &lt;strong&gt;associative²&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Functor&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Imagine now that we find another map, this time the map of the Seven Kingdoms of &lt;strong&gt;Game of Thrones&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqibdnmnsxltpu8io0c3.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqibdnmnsxltpu8io0c3.jpeg" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Again, we have towns and roads linking these towns. That is, we have another category.&lt;/p&gt;

&lt;p&gt;Look at the roads that link each town. Can you find some similarity? For example, is there any town that no one wants to go to? Of course, who would want to go to Meereen? Nobody!&lt;/p&gt;

&lt;p&gt;Another example is that there is a town that can be reached from all other towns. Look, at the Middle Earth one too!&lt;br&gt;
In fact, it has so many similarities we could say that if we change names and distances, it is the same map (in mathematics it is said to have &lt;strong&gt;the same structure&lt;/strong&gt; and, in the real world, we say George R.R. Martin was “strongly inspired” by the Tolkien’s work)³.&lt;/p&gt;

&lt;p&gt;Seeing this, it is clear that we should be able to transform, the map of the Middle Earth in the Seven Kingdoms, but … how?&lt;br&gt;
The first thing we have to think about is a transformation the towns, in this case:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZFp_pvcs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A6Oq0pKYf-aL3i2O8." class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZFp_pvcs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2A6Oq0pKYf-aL3i2O8." width="631" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last thing we have to do is transforming the roads:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgiv2qncp6yvrt0mhftp9.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgiv2qncp6yvrt0mhftp9.jpeg" width="800" height="621"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldq2m1o6fqoq01upv9d1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldq2m1o6fqoq01upv9d1.jpeg" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oXgSTO7X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AOulU2-oAXWYXBK_g." class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oXgSTO7X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AOulU2-oAXWYXBK_g." width="195" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A very important thing about this transformation is that it preserves the structure, including the composition: Frodo going from the Shire to Erebor (optionally going through Rivendell) would be similar to a trip made by John Snow from The Wall to King’s Landing (also optionally passing by The Eyrie).&lt;/p&gt;

&lt;p&gt;We can say that this transformation… It’s a &lt;strong&gt;Functor&lt;/strong&gt;! In this way, we have been able to transform “completely different” worlds, exactly what the category theory in mathematics was created for: to build bridges between very different fields.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monad&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Now we have found another map of the Middle Earth, but this time, drawn by a &lt;strong&gt;Dwarf&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnnlox0gvelugnfa67lo.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnnlox0gvelugnfa67lo.jpeg" width="800" height="563"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, the Middle Earth is the same, so it must have (and has) the same populations, and the same roads. Of course with so many maps, it would be difficult It to get lost …&lt;/p&gt;

&lt;p&gt;As it is essentially the same map, it is clear that we can also construct a functor or a transformation of the Middle Earth itself, which is the same. This special type of functors is known as endofunctors.&lt;/p&gt;

&lt;p&gt;But there is more. If an endofunctor also fulfills that it has two natural transformations such as the identity function and another function that is associative, we can say that we have a monad (this we call &lt;strong&gt;monadic laws&lt;/strong&gt;)⁴.&lt;/p&gt;
&lt;h2&gt;
  
  
  Monads in functional programming
&lt;/h2&gt;
&lt;h3&gt;
  
  
  History:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf" rel="noopener noreferrer"&gt;Philip Wadler,&lt;/a&gt; who is the greatest contributor to the theory behind functional programming and the use of monads, was inspired by the use of Eugenio Moggi’s monads to give semantics to programming languages. The monads introduced the idea of ​​sequence into the functional paradigm, but without contradicting it, thanks to the composition of functions.⁵&lt;/p&gt;

&lt;p&gt;Many common programming concepts can be described in terms of monad structures, including side effects, I/O, exception handling…&lt;/p&gt;

&lt;p&gt;This allows such concepts to be defined in purely functional ways without the need to add new terms to language semantics and without resorting to imperative programming. There are languages ​​like Haskell that provide monads in the standard kernel and, although Scala does not provide it in the kernel, you are familiar with &lt;a href="http://typelevel.org/cats/" rel="noopener noreferrer"&gt;Cats&lt;/a&gt; and &lt;a href="https://github.com/scalaz/scalaz" rel="noopener noreferrer"&gt;Scalaz&lt;/a&gt; libraries that help us develop with monads (although we can always implement our own).&lt;/p&gt;
&lt;h3&gt;
  
  
  Functors and monads in FP:
&lt;/h3&gt;

&lt;p&gt;It has been nice explaining how the category theory in mathematics works but, as developers, we already want to see an example applied to functional programming:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86uvhq2kgy2ndudly88m.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86uvhq2kgy2ndudly88m.jpeg" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This drawing⁶ represents a functor, in this case, composed of &lt;strong&gt;List&lt;/strong&gt; and &lt;strong&gt;map&lt;/strong&gt;. Surely you have already linked this example with the one of the Lord of the Rings and Game of Thrones´s functor.&lt;/p&gt;

&lt;p&gt;You may have read online that List is a functor per se, just like the Scala Option class is a monad. Both are type constructors (that would be equivalent to the transformer of towns) but… where is the transformer of roads/arrows? This is a very frequent abuse of language that you will no longer see with the same eyes.&lt;br&gt;
&lt;strong&gt;If in the previous drawing we had used flatMap instead of map&lt;/strong&gt; (flatMap’s output is in the same category), &lt;strong&gt;we would have drawn a monad&lt;/strong&gt; (although we need to check the monadic laws) instead of a functor.&lt;/p&gt;

&lt;p&gt;There are many reasons to use monads in our programs, but I will list the top 3 main reasons (in my humble opinion) to use them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;At the end of the day, we only want to use functions (remember: functional programming).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Imagine that you have a program that performs these two functions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;f(x) = x+3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;g(x,y) = List(x, y)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We want these two functions to be executed in order, sequentially, and we want to do it using only functions. So, how could we do it? Using composition of functions. If we first want to execute g and then f on the result, we compose the functions in the next way: &lt;strong&gt;f ∘ g (x, y)&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If instead of the previous g, we use &lt;strong&gt;g(x, y) = x / y&lt;/strong&gt;, we have two problems:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the &lt;strong&gt;type&lt;/strong&gt; that accepts f &lt;strong&gt;is different&lt;/strong&gt; from the one that returns g (g could return a float since it is a division, and f accepts an Int) we would clearly have a problem.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What would happen if the function g passed the values ​​2 and 0? Indeed, there would be a failure since it can not be divided by 0. We do not want exceptions in functional programming since an &lt;strong&gt;exception is not a function&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What I mean is that the composition of functions needs one more ingredient to be 100% functional (this ingredient will also solve the two problems above). This ingredient, obviously (judging by the title of the post ;)), is the use of monads.&lt;/p&gt;

&lt;p&gt;The idea is to allow functions to return two types of results, so g would no longer be: g: Int, Int → Float, but we would do that &lt;strong&gt;g: Int, Int → Some | None&lt;/strong&gt; and &lt;strong&gt;f(x): Some | None → Some | None&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, we are going to undo the functions with the previous example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scala"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;g&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="k"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="k"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="k"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;Float&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="k"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;None&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Some&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;x&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;toFloat&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the same with f(x):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scala"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="k"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;Float&lt;/span&gt;&lt;span class="o"&gt;])&lt;/span&gt;&lt;span class="k"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="k"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;None&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;None&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Some&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Some&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;x&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;asInstanceOf&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="o"&gt;]+&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So our code would be &lt;strong&gt;g(x, y).flatMap (x =&amp;gt; f (Option (x)))&lt;/strong&gt;. In this way, we have composed the two functions and avoided the exceptions, since if y is equal to 0 the result will be None.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary and conclusions
&lt;/h2&gt;

&lt;p&gt;In short, we can say that a monad is an endofunctor which holds monadic laws. We can also say that thanks to the monads, we can compose functions, solving type problems and exceptions.&lt;/p&gt;

&lt;p&gt;Now that we know the category theory a little better and how some of these concepts are used in functional programming, we can use the tools provided in our programs to make a better code.&lt;/p&gt;

&lt;p&gt;Go, you can already tell your friends “I’ve seen things you people wouldn’t believe”.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; That is, if Frodo goes from The Shire to Erebor (f) and then stays in Erebor (identity) is the same as if he goes directly to Erebor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; That is, if we take five paths, for example that one which goes from The Shire to Erebor (f), that one which goes from Rivendell to the Shire (g), that one which goes from Mordor to Rivendell (h), that one which goes from Rivendell to Erebor (j) and that one which goes from Mordor to The Shire (k). Then (f &lt;strong&gt;∘&lt;/strong&gt; g) &lt;strong&gt;∘&lt;/strong&gt; h = f &lt;strong&gt;∘&lt;/strong&gt; (g &lt;strong&gt;∘&lt;/strong&gt; h) since f &lt;strong&gt;∘&lt;/strong&gt; g = j and g &lt;strong&gt;∘&lt;/strong&gt; h = k.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; Obviously, the paths of these maps are carefully invented so that everything fits perfectly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; &lt;a href="https://wiki.haskell.org/Monad_laws" rel="noopener noreferrer"&gt;Monadic laws&lt;/a&gt; with composition operation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;F ∘ id = F (&lt;strong&gt;Left identity&lt;/strong&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Id ∘ F = F (&lt;strong&gt;Right identity&lt;/strong&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(F ∘ G) ∘ H = F ∘ (G ∘ H) (&lt;strong&gt;Associativity&lt;/strong&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; &lt;a href="https://www.amazon.com/Euclides-Historia-algoritmos-lenguajes-programaci%C3%B3n/dp/8496566145" rel="noopener noreferrer"&gt;De Euclides a Java — Ricardo Peña Mari&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.&lt;/strong&gt; &lt;a href="http://nikgrozev.com/2016/03/14/functional-programming-and-category-theory-part-1-categories-and-functors/" rel="noopener noreferrer"&gt;Based on Nikolay Grozev’s one&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources and links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf" rel="noopener noreferrer"&gt;Paper from Phillip Wadler where he explains monads&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://www.sciencedirect.com/science/article/pii/0890540191900524" rel="noopener noreferrer"&gt;Eugenio’s Moggi work about monads&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://bartoszmilewski.com/" rel="noopener noreferrer"&gt;The omniscient Bartosz Milewski&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://repository.eafit.edu.co/bitstream/handle/10784/4551/VillaIsaza-2011%20Practica-investigativa-I%20Teoria-de-categorias-aplicada-a-la-programacion-funcional-con-Agda.pdf?sequence=2" rel="noopener noreferrer"&gt;The Juan Pedro Villa-Isaza’s work around applications of category theory in functional programming&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://devth.com/2015/monad-laws-in-scala" rel="noopener noreferrer"&gt;The Trevor Hartman’s post about monad laws in Scala&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://typelevel.org/cats/" rel="noopener noreferrer"&gt;Cats library&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wikipedia’s articles on &lt;a href="https://en.wikipedia.org/wiki/Category_theory" rel="noopener noreferrer"&gt;category theory&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Monad_(functional_programming)" rel="noopener noreferrer"&gt;monads&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.amazon.com/Euclides-Historia-algoritmos-lenguajes-programaci%C3%B3n/dp/8496566145" rel="noopener noreferrer"&gt;A work about programming history: De Euclides a Java — Ricardo Peña Mari&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://nikgrozev.com/2016/03/14/functional-programming-and-category-theory-part-1-categories-and-functors/" rel="noopener noreferrer"&gt;The Nikolay Grozev’s post about functors&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/28139259/why-do-we-need-monads/" rel="noopener noreferrer"&gt;A stack overflow’s post&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html" rel="noopener noreferrer"&gt;A post about functors and monads&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;This post originally appeared on &lt;a href="http://www.datio.com/development/knowing-monads-through-the-category-theory/" rel="noopener noreferrer"&gt;Datio’s Blog&lt;/a&gt; on June 26, 2017.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>monads</category>
      <category>functional</category>
      <category>scala</category>
      <category>maths</category>
    </item>
  </channel>
</rss>
