DEV Community

Tom Sherman
Tom Sherman

Posted on • Originally published at github.com

1 2

Is a burrito a monad?

This post was originally posted on my blog.


As we all know, a monad is just a monoid in the category of endofunctors. This is intuitive to you and I, but what if you need to explain what a monad is in more practical terms. Well that's where the three laws of monads come in.

These three laws act as a test to tell if something is a monad - if that something passes the three laws, then it's a monad - simples.

Now to the main event, is a burrito monad? Well let's see if it obeys the three laws...

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.

Thus the burrito passes the third law.

The burrito is a monad 🌯

Further reading

Burritos for the Hungry Mathematician by Ed Morehouse

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (1)

Collapse
 
realtomaszkula profile image
Tomasz Kula

lmao

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay