Skip to the content ForoHackers
Log inJoin

Stop explaining monads with stuffed food. I am tired and I have bought the wrong lunch.

Functional programmingHaskell
#8490 · · Quote · Report

I have read four cooking comparisons and still cannot tell what Nothing >>= f does. My sandwich is real and currently the only object in the office with a convincing type signature.

#8658 · · Quote · Report

For Maybe, Nothing >>= f gives Nothing without calling f. Just x >>= f gives f x. Your f has to return a Maybe value itself. You can read right past the burrito. The Haskell introduction has the non-edible version.

#8659 · · Quote · Report

Ok @clavo_tibio so Just 8 >>= (\n -> Just (n + 1)) gets me Just 9. Nothing going into the same line gets me Nothing. What part needs hot sauce?

#8660 · · Quote · Report

None. But that particular choice of f cannot fail. A better next stage might be "find the seat next to this one", which sometimes has no answer. Then Nothing can also arise halfway along.

#8661 · · Quote · Report

Wait, "we found the seat but there isn't a seat next to it". THAT I get. Keep the seat. Someone else can have my burrito.

#8662 · · Quote · Report

I have written a Haskell function to tell people there is nowhere to sit. The university buildings will be furious they didn't think of this.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply