this post was submitted on 11 Oct 2025
187 points (94.7% liked)

Programmer Humor

26827 readers
2369 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] mEEGal@lemmy.world 15 points 12 hours ago (6 children)

Seriously, can someone please explain monads like we're dumb or something ?

[–] nik9000@programming.dev 2 points 4 hours ago

I'm not good at this but that's never stopped me from making a fool of myself before.

Iterators are monads because they have a flatMap on them. It takes each element and spits out a new iterator which is merged in to the result.

Option is a monad too. Same reason. You can map the contents to another option. And you won't get called if there's nothing inside.

Promises are monads too. You can map the result to another promise. The wrinkle here is that you don't get to know when the map happen. Or it might not get called at all if the promise errors out.

IO can be a monad because you can ask it for input and wait for the result. It's just the same as a promise.

See how these different things share a common behavior? That's monad. Or, maybe it's monoid. Names are hard and I'm busy making a fool of myself.

Monads are nothing more than a useful abstraction. Haskell is famous for them because they couldn't make Haskell do imperative stuff without them so they spread them all over the language.

We all use them every day in regular programming. We just don't think of them as a class of thing.

[–] bss03 2 points 5 hours ago

http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html

It's a "programmable semicolon" or "decorated-function composition". I think most people that are confused about it, are trying to make it be more meaningful than it is. Haskell (?) just grabbed a math name so they'd have one word for it, because it's a useful class name there.

[–] someacnt@sh.itjust.works 3 points 9 hours ago

Monad is (a classes of type of) a collapsible container. Collapsible, like how you can flatten a nested list, or Option<Option> can be flattened to Option.

A common pattern with monads is the flatMap function, where you apply function A -> List to (each element of) List to obtain List. This happen to represent erroneous call chaining with Option or Result types.

[–] magic_lobster_party@fedia.io 5 points 11 hours ago

It’s like a burrito