by raverbashing · 13y ago · 0 comments
Technical people can't go straight to the point. They go around, around, around, going into corners, etc
(not only on explanations, mind you)
For example, math has some very high-level/generic explanations, and curiously, I find them more understandable.
So, I've given up on understanding Monads (or at least Haskell ones), I'll probably understand them when I come up with a similar problem and think about how to solve them.
1) Just 1 >>= \_ -> Just 2
2) Just 1 >>= \_ -> Nothing
3) Just 1 >>= \_ -> Nothing >>= \_ -> Just 2
4) Just 1 >>= \x -> Just(x+1)
5) Nothing >>= \x -> Just(x+1)
6) Just 1 >>= \x -> Just(x+1) >>= \x -> Just(x+1)
7) Just 1 >>= \x -> Just(x+1) >>= \y -> Just(x)
If you can answer all of those correctly, you should have a decent understanding of monads.answers:
1) Just 2
2) Nothing
3) Nothing
4) Just 2
5) Nothing
6) Just 3
7) Just 1That's because math always "goes straight to the point". There's nothing but the raw substance in it.
Especially if you don't know the names used in the description.
The problem is that I can't stand explanations that would go like this if it was explaining Math:
"So, we have a natural number, that is 2, 7, or 34232345 and by the way they're all integer numbers as well, also they are rational numbers as well, oh and there's equation you can do with them, but ok, so you can sum those numbers, etc"
I'd rather go with
"This turns the natural numbers (N, +) into a commutative monoid with identity element 0,"
I think this is the best monad introduction I've seen: http://blog.sigfpe.com/2006/08/you-could-have-invented-monad... It shows you why monads are a thing, what kinds of problems they can be used to solve, and then you see the overall pattern of how those different problems share the same underlying pattern (they are monads).