Live data from Hacker News

Monads are monoids in the category of endofunctors

sambernheim.com

11–20 of 241 posts

Re: Monads are monoids in the category of endofunctors

#11
post #5

Wait, a functor is just a pure unary function? And an endofunctor is just one of those where the argument type and return type are the same? This could have been explained to me years ago, in five minutes? Sometimes it makes me mad that so much confusion (and as another commenter put it, gatekeeping) has been sown in FP circles through the invention of pointlessly-obfuscated terminology for everything (and through -…

> Wait, a functor is just a pure unary function?

And guess what another name for a unary functions is... 'monadic'.

Re: Monads are monoids in the category of endofunctors

#13
post #5

Wait, a functor is just a pure unary function? And an endofunctor is just one of those where the argument type and return type are the same? This could have been explained to me years ago, in five minutes? Sometimes it makes me mad that so much confusion (and as another commenter put it, gatekeeping) has been sown in FP circles through the invention of pointlessly-obfuscated terminology for everything (and through -…

Honestly most of what I've learned in category theory is just terminology. 2 Dozen flash cards would really take all the mystery away

And for those of us who struggle with rote memorization, it's a huge artificial barrier.

Though in my experience even the "flash cards" are hard to find on the internet.

Re: Monads are monoids in the category of endofunctors

#14
post #2

raises the question* Begs the question has a specific meaning. https://en.m.wikipedia.org/wiki/Begging_the_question

Language changes over time: https://www.merriam-webster.com/words-at-play/beg-the-questi...

Yes, I’m aware that nonsense can be introduced into our lexicon by a sufficiently large population of people misusing meaningful phrases.

Re: Monads are monoids in the category of endofunctors

#15
post #5

Wait, a functor is just a pure unary function? And an endofunctor is just one of those where the argument type and return type are the same? This could have been explained to me years ago, in five minutes? Sometimes it makes me mad that so much confusion (and as another commenter put it, gatekeeping) has been sown in FP circles through the invention of pointlessly-obfuscated terminology for everything (and through -…

> a functor is just a pure unary function?

No, although a pure unary function could be viewed as a functor, the other direction doesn't hold.

The common FP definition of a functor is anything that supports a notion of `map` (subject to the restriction that `map`ping the identity function does nothing, this is why a Functor is slightly more than just a Mappable). This is not a unary function although map takes a unary function as an argument.

The more general mathematical definition is a mapping between categories. Categories are sufficiently general that you can view almost anything as a category, which is why a unary function can be thought of as a functor (because a functor can be a mapping between categories that happen to be sets).

But a functor is both more general than a unary function and, in a certain sense, preserves more structure than a function, since it must preserve the structure of the underlying categories whereas functions generally only care about sets.

Re: Monads are monoids in the category of endofunctors

#16
post #2

raises the question* Begs the question has a specific meaning. https://en.m.wikipedia.org/wiki/Begging_the_question

Language evolves, as the wiki article you linked describes. Your prescriptivist nit-picking doesn't contribute to the discussion.

From the HN guidelines:

  - Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith.
  - Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something.
  - Eschew flamebait. Avoid unrelated controversies and generic tangents.

Re: Monads are monoids in the category of endofunctors

#17
post #3

Functional programming is subject to an enormous amount of gatekeeping. Kudos to the author for pushing that gate wide open.

Agree. Too often descriptions of monads assume that the reader has no formal math training whatsoever and do a lot of handwaving, diagrams, examples, etc. without actually providing a useful definition. This post is the exact opposite.

The closest I’ve come to understanding monads is the Wikipedia page on them (in the functional programming context, there’s also a separate monad page in the context of category theory specifically which is a lot more jargon heavy)

https://en.m.wikipedia.org/wiki/Monad_(functional_programmin...

Re: Monads are monoids in the category of endofunctors

#18
There’s a few gaps in this explanation that my deductive completionist brain is looking for.

Namely, I’m wondering what kind of thing is even capable of being a monoid and an endofunctor at the same time. Mathematically, a monoid is a set (or collection to be more general) closed under a binary operator (the monoidal product) and with a distinguished identity element. An endofunctor is a mapping from a category to itself, which entails a mapping of each object as well as a mapping of each morphism. So I’m not even sure how to parse the phrase “monoid in the category of endofunctors” because the data required to describe these two things seems completely different.

Re: Monads are monoids in the category of endofunctors

#19
post #2

raises the question* Begs the question has a specific meaning. https://en.m.wikipedia.org/wiki/Begging_the_question

Language evolves, as the wiki article you linked describes. Your prescriptivist nit-picking doesn't contribute to the discussion. From the HN guidelines: - Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith. - Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something.…

I’m helping the dude improve his writing with a short and minimally critical comment.

Hall monitor elsewhere.

Re: Monads are monoids in the category of endofunctors

#20
post #5

Wait, a functor is just a pure unary function? And an endofunctor is just one of those where the argument type and return type are the same? This could have been explained to me years ago, in five minutes? Sometimes it makes me mad that so much confusion (and as another commenter put it, gatekeeping) has been sown in FP circles through the invention of pointlessly-obfuscated terminology for everything (and through -…

Functors are type constructors, not functions (which map values). But you could be forgiven the misunderstanding, because it is easy to trip over this distinction given the identical syntax.

So, to make this absolutely clear, a monad is a type constructor in functional programming. This is why I personally prefer the more “creative” explanations of monads, because they attempt to explain what the monad is doing to the original type: adding context, or the possibility of a null value, or multiple values, or a probability distribution over values, etc.

Post reply on HN