
A monoid is a category, a category is a monad, a monad is a monoid - graphlinalg
https://graphicallinearalgebra.net/2017/04/16/a-monoid-is-a-category-a-category-is-a-monad-a-monad-is-a-monoid/
======
crawfordcomeaux
For anyone wondering how this is useful outside of programming and/or looking
for an easier introduction, check out Category Theory for the Sciences [1].
There are free digital versions on Github, too [2]. Here's the reasoning given
by the author:

"Information is inherently dynamic; the same ideas can be organized and
reorganized in countless ways, and the ability to translate between such
organizational structures is becoming increasingly important in the sciences.
Category theory offers a unifying framework for information modeling that can
facilitate the translation of knowledge between disciplines."

[1] [https://mitpress.mit.edu/books/category-theory-
sciences](https://mitpress.mit.edu/books/category-theory-sciences)

[2] [https://github.com/mmai/Category-Theory-for-the-
Sciences](https://github.com/mmai/Category-Theory-for-the-Sciences)

------
jingwen
For anyone interested to start on this subject, Philip Wadler's Category
Theory for the Working Hacker [1] is an excellent introductory lecture for
building an intuition.

[1]
[https://www.youtube.com/watch?v=V10hzjgoklA](https://www.youtube.com/watch?v=V10hzjgoklA)

~~~
irfansharif
just to note this talk briefly alludes to another subject, the Curry–Howard
isomorphism, something Philip Wadler had similarly given a talk about at
Lambda Days (2016) titled 'Propositions as Types'[1] (slides [2] and the video
recording[3]).

[1]: [http://www.lambdadays.org/lambdadays2016/philip-
wadler](http://www.lambdadays.org/lambdadays2016/philip-wadler)

[2]:
[http://www.lambdadays.org/static/upload/media/14562260715188...](http://www.lambdadays.org/static/upload/media/1456226071518855propositionsastypeskrakow.pdf)

[3]: [https://youtu.be/aeRVdYN6fE8](https://youtu.be/aeRVdYN6fE8)

~~~
rocqua
That youtube lecture was really interesting.

The very ending was awesome as well!

------
casion
Are there really that many people on NH that can understand this?

I'm not trying to be snarky, I'm legitimately interested. It seems like this
class of knowledge is highly specialized, yet I see posts like these high up
on NH frequently.

~~~
tikhonj
I work at Target and we have a weekly class on algebra, category theory and
Haskell because people are interested. It's a mix of programmers learning some
of the math and mathematicians learning some of the programming :).

It's actually a lot more accessible than it seems at first—these ideas are not
_complex_ , just abstract. Thinking at a high level of abstraction is very
much a skill which requires specific training, but it's a skill _worth_
training and, when you have it, learning things like this becomes much easier.

The same thing is true of programming, by the way: once you start "thinking
like a programmer", it becomes much easier to learn a new programming language
or to understand some low-level programming concepts. And thinking like a
programmer is, in the grand scale of things, not _that_ different from
thinking like a mathematician!

~~~
zengid
Is this at the HQ in Minneapolis? I hope to move back to MN someday (to raise
the younglings) and you make Target sound awesome!

~~~
tikhonj
Currently we're a small team mostly based in Sunnyvale, but we're also partly
distributed and have some people in Minneapolis. This has been a bit awkward
for the class specifically because teaching people over Hangouts turns out to
be _hard_ , but there is certainly some cool work going on in Minneapolis.

~~~
mitchty
As someone in the Twin Cities, BAH, I was hoping to find more haskellers
around. Oh well, I'll keep trying to get more FP stuff in where I work at
least.

------
lyall
For those want a great intro and overview of category theory aimed at
programmers, Bartosz Milewski's lecture series on YouTube [0] is worth the
time investment. It covers the topics this post discusses and more, but
crucially with plenty of context to help understand why any of it matters.

0:
[http://www.youtube.com/playlist?list=PLbgaMIhjbmEnaH_LTkxLI7...](http://www.youtube.com/playlist?list=PLbgaMIhjbmEnaH_LTkxLI7FMa2HsnawM_)

~~~
bojo
Was checking to see if anyone has posted this. Am in the middle of the
lectures and they are absolutely fantastic.

------
snowcrshd
I recently started going through Bartoz Milewski's Category Theory lectures
[1]. I think they are a very nice place to start learning these things.

[1]
[https://m.youtube.com/watch?v=I8LbkfSSR58](https://m.youtube.com/watch?v=I8LbkfSSR58)

~~~
krick
Watched 1.25 videos (basically, where he drops philosophy and ought to get
into real explanations), and am starting to feel dissatisfaction I always feel
when try to learn about this stuff from programmers. What I always expect is
mathematics, explained informally for easier understanding. What I get is not
mathematics, I can even say he is starting to sound mystical. For instance, he
says "bunch of objects". He understands, that "bunch" is a weird term
(actually, not a term at all) and it might seem he could use word "set"
instead, but he can't. Why he can't? He doesn't really explain, he just starts
delving into some weird narratives of "set-theorists everywhere see set-nails,
because they have a set-hammer" and "because paradoxes". But if you actually
studied set theory (and I guess every programmer does at some point, or at
least should to) you know ZFC was basically created to help to get rid of
these paradoxes, so it still isn't clear why a "bunch" isn't a "set".

So you go to the Wikipedia and learn there is a word "class" (no more complex
than a word "bunch" at all, in my opinion) and there exists simple, very much
set-theoretical explanation of what is (or might be in different set-theory
systems) a class, and why it might be not a set sometimes.

Then he starts with arrows, and again, from the explanation it isn't
immediately obvious why he can't use a word "function" instead (and it is
immediately obvious when you read definition of category on Wikipedia — and I
got used to the fact Wikipedia isn't the best source by far when trying to
learn math).

So, my real complaint is these guys are consciously not using mathematics
(because math texts are "scary" — and, yeah, I agree, they often are) when
essentially explaining mathematics. Category theory isn't some different
discipline, it isn't "superset" of mathematics — it _is_ mathematics. Informal
is good when it isn't "imprecise", otherwise it's just useless and harmful. I
sometimes think it might be easier to actually get used to (once more all over
again) all math-talk and read something like "Categories for a working
mathematician", instead of trying to decipher all these "simpler" informal
explanations.

------
BucketSort
I've been studying Leibniz recently and I'm excited to get to his treatment of
Monads. The following is a little irrelevant to this post, but the title of
this post stirred a relationship.

So to Leibniz, in the conception of an entity's identity, he posits that one
must include all propositions related to that entity. So when we try to
consider a property of an object of our mind, we are basically saying "it is
what it is." Saying that Einstein is German is like saying "Einstein is
Einstein." Where this conception of including propositions in identities gets
weird is that his formulation also includes future propositions. In this
respect, only God can truly understand anything fully, because only he can
tell the future and can get the full identity of things.

So "x is x" shows up a lot.

Edit: As mentioned, Leibniz Monad != the Monad of category theory. I suppose
I'm just looking for any excuse to talk about Leibniz. Also, I did say I
didn't even get to that topic yet. Consider this a peep about the duality of
that term.

~~~
IgorPartola
If god was all powerful, he could create a rock he himself could not lift.

If god was all knowing, he could create a cryptosystem he himself could not
break.

God is a bad measure of physical properties. Some things are just unknown.

~~~
posterboy
Chuck Norris could create a rock so heavy he himself could not lift it ... and
then he would lift it.

~~~
yeahGreat
It's not funny anymore.

------
krick
There's interesting table on wikipedia's Category[0] page, listing group-like
structures. It is easy to find useful example of Abel group and useful example
of Group which is not Abel group (say, string concatenation with negation
defined as ab - b = a), but while I clearly understand definition of monoid, I
cannot think of any useful example of monoid which is not group.

Can somebody help with examples for the rest of structures? Additionally, it
seems I don't really get concept of totality. I get what "total function" is,
but what does this column really constraint in the context of different
structures? I mean, what is a structure that lacks this "totality" thing?

[https://en.wikipedia.org/wiki/Category_(mathematics)](https://en.wikipedia.org/wiki/Category_\(mathematics\))

~~~
nwjtkjn
The natural numbers {0, 1, 2, ...} under addition are an example of a monoid
which is not a group. Another example is natural numbers under multiplication.

An example which may speak to a programmer more: the set of functions which
take a 32-bit int as argument and return a 32-bit int, where the operation is
composition of functions. The identity is the identity function. Since not all
functions are invertible, this monoid is not a group.

~~~
krick
Oh, silly me, of course, negation must be defined for _every_ pair of
elements. Ok, it's pretty clear about monoids (even though actually it would
be better if there was an example, where no "natural" inversion exists at
all). But what about everything else in the table? Especially I'm interested
in magma which is not a semigroup and groupoid which is not a group.

~~~
nimih
Binary trees, with the operation being to join two trees at the root, form a
magma which should quite clearly be non-associative (and thus not a
semigroup).

There are of course other examples of sets equipped with non-associative
binary operations (for example, 3-dimensional vectors with the cross product),
but those typically have extra structure that you will want to exploit which
"non-associative magma" cannot capture, and talking about them as magmas will
probably feel somewhat artificial unless you have a good reason for ignoring
all that structure.

------
phab
The author's (eponymous) series on Graphical Linear Algebra is well worth
reading, and has some interesting parallelisms to boolean functions & their
manipulation.

------
crawfordcomeaux
In most of the category theory posts on HN I've seen, there's at least one
person asking ahead this stuff is useful for. This comment is about why I find
it useful.

Why I learn this stuff: to more effectively change things about myself.

Category Theory is an abstract math of relationships. I use it to better
understand how my mind and body work. How parts of me are related in the
moment and/or across time. Understanding how things in me are related is
essential to me dealing with PTSD & recovering from addiction, both of which
can color every aspect of a person. Untangling them is insanely hard and has
gotten much easier through CT.

I apply my programming intuition to my brain & body through CT. There exists a
path from neuroanatomy to theoretical computer science that passes through
category theory. I've been experimenting on myself for 6 months with the goal
of changing my mind and body. I've been doing it by developing an intuition
for category theory, developing an intuition for how neutral networks learn,
adapting machine learning models with concepts from neuroscience and
psychology, and mixing it all with my intuition for programming.

So far, I've:

• changed how I walk through a handful of sessions lasting a few minutes and
no longer experience back pain I'd been seeing a chiropractor (saw him weekly
for 3-4 months with little improvement, ending about 10 months people changing
my gait)

• began learning how to identify and stop believing anxious thoughts

• accidentally started developing the ability to focus and direct my attention
(way beyond anything I've ever experienced on my ADHD meds)

• accidentally stumbled on the Buddhist practice of deity visualization, which
created a second conscious voice in my head. She helps me learn how to embody
more than one new personality trait at a time easier than if I simply focused
on being those things. It's weird/complicated, and I'm willing to go into more
detail if people have questions.

Here are some of the few bits supporting my claims about neuroanatomy and
category theory:

[https://www.researchgate.net/publication/280219255_Conciliat...](https://www.researchgate.net/publication/280219255_Conciliating_neuroscience_and_phenomenology_via_category_theory)

One of the coauthors wrote the only book on the brain and category theory:

[http://tierra.aslab.upm.es/documents/PhD/PhD-
JGomez.pdf](http://tierra.aslab.upm.es/documents/PhD/PhD-JGomez.pdf)

If you understand a good bit of CT and would like to help me flesh out my
framework, my contact info is in my profile.

I live in the Seattle area and would love to meet up with anyone interested.

~~~
crawfordcomeaux
Does anyone have constructive criticism to go along with the downvotes?

~~~
socmag
The downvote button should be banished is my only constructive criticism.

As far as the rest, I'm largely right there with you. I also use what you call
the "second conscious voice" as well, and agree it's extremely helpful if not
abused, plus some of the other stuff too.

I used to live in Seattle btw but back in Europe for a while at the moment
otherwise would have loved to chat.

You sound to be on a good path. Best.

