this post was submitted on 02 Jul 2023
197 points (94.6% liked)

Programmer Humor

19691 readers
85 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 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] expr 7 points 1 year ago* (last edited 1 year ago)

JavaScript promises are not monads: https://stackoverflow.com/questions/45712106/why-are-promises-monads

They're close, but not quite. then can shift semantics from under you depending on what's supplied.

It should also be added that monoids require the type to have an identity or "empty" value (which is the empty array for arrays).

The explanation is pretty off in general, since it implies that any type that's both a functor and a monoid is a monad, which is simply not true. A good example is a ZipList (like lists, but with an applicative instance based on zipping). It's a functor and a monoid, but definitely not a monad.