flâneur — a map of the web's best reading

What is a Monad?

lukechampine.com · 1,163 words · saved by 1 readers

What is a Monad? ================ Note: this article assumes some familiarity with Haskell. A monad is a monoid in the category of endofunctors. That's usually given as a joke answer, but it's true. And I think it's the proper way to explain what monads are and why they're useful. First, let's go over what a monoid is. A monoid has three components: - A category - An associative binary operation on that category - An "identity value" for the operation The easiest example is addition on the natural numbers. Here, the identity value is 0, because adding 0 to any number does not change it. Also note that addition is an associative operation; that is, (1 + 2) + 3 = 1 + (2 + 3). Similarly, multiplication is a monoid with identity value 1. However, we can easily show that subtraction and division are not monoids, because they are not associative: (1 - 2) - 3 ≠ 1 - (2 - 3). Given this definition, we can easily construct our own monoid. For example, our category could be shopping lists

What is a Monad? What is a Monad? ================ Note: this article assumes some familiarity with Haskell. A monad is a monoid in the category of endofunctors. That's usually given as a joke answer, but it's true. And I think it's the proper way to explain what monads are and why they're useful. First, let's go over what a monoid is. A monoid has three components: - A category - An associative binary operation on that category - An "identity value" for the operation The easiest example is addition on the natural numbers. Here, the identity value is 0, because adding 0 to any number does not

Explore this link on the map →

saved by

related reading