gaearon / whatthefuck.is

An opinionated glossary of computer science terms for front-end developers. Written by Dan Abramov.
https://whatthefuck.is
Other
3.04k stars 116 forks source link

WTF is a Monad? #5

Open lyovson opened 4 years ago

lyovson commented 4 years ago

Someone had to do it, so here I am]]

tom-sherman commented 4 years ago

A monad is just a monoid in the category of endofunctors, what's the problem?

gillchristian commented 4 years ago

A monad is a burrito :burrito:

(wrong answers only right?)

tom-sherman commented 4 years ago

I think you could be onto something...

Left identity - take your filling, put it in a burrito - toast it - take the filling back out - the filling is warm just as if you toasted the filling itself. So the burrito passes the first law.

Right identity - unwrap the burrito to get to the filling. The burrito passes the second law.

Associativity - putting hot sauce in your burrito and then toasting it is the same as toasting it and putting hot sauce in your burrito. The burrito passes the third law.

The burrito is a monad 🌯

lyovson commented 4 years ago

Ok, got it, a monad is a burrito a box of endofunctors. Right?

naingaungphyo commented 4 years ago

This is interesting Maybe topic!

silvanocostanzo commented 4 years ago

+1

evertbouw commented 4 years ago

Something being a Monad just means it flatmaps.

sdball commented 4 years ago

Putting in hot sauce and then toasting is not the same as toasting and then putting in hot sauce. Toasting hot sauce changes the properties of the hot sauce.

jseling commented 4 years ago

Need make a WTF is an Endofunctor? first. Maybe a WTF is a Functor? before. And a WTF is Category theory first at all.

eltonvs commented 4 years ago

I had to link this here: https://youtu.be/BoJGIqyriCc

joms commented 4 years ago

Yeah, wtf is a monad? https://twitter.com/dan_abramov/status/1285925737258717190