3 ms·
From my own experience teaching Haskell, monads are incredibly hard to explain in terms that are easy for CS students with a systems programming background to u
by dserban 12y ago
From my own experience teaching Haskell, monads are incredibly hard to explain in terms that are easy for CS students with a systems programming background to understand.
They are easy to explain to 2nd or 3rd year math students.
The difference is in the audience's cognitive bias.
- AnimalMuppet 12y agoIf I understand correctly (and I may not), monads live in two different worlds. A (Haskell) monad has to be a (mathematical) monad. Haskell is counting on it not just to have certain function signatures, but to have certain properties - certain identities that it satisfies. This lets Haskell do some transformations under the hood. If you hand Haskell something that you say is a monad, and it doesn't satisfy the identities, you're going to get some really unpredictable results. That's the part that's easy to explain to 2nd or 3rd year math students. But, unless you're writing an application in group theory, as a programmer you don't really need a monad. You need something that will let you operate on a value that's in a Maybe, and therefore you need a monad. That is, you don't care about it being a monad for the sake of monads, you care about it as a way to solve a particular programming problem. That's the part that's hard to explain to CS students. They just want to operate on a Maybe. They don't understand why they have to care about it being a monad, or what the connection is between "monad" and "a kind of smuggler that will smuggle this function in to operate on a value that's stuck in jail in a Maybe" (or whatever analogy they're using). If you see a place my understanding can be improved, feel free to correct it...