4 ms·
I've recently finished reading Learn You A Haskell For Great Good!, and I think the author's approach to monads works well. I'd read various metaphorical explan
by necubi 16y ago
I've recently finished reading Learn You A Haskell For Great Good!, and I think the author's approach to monads works well. I'd read various metaphorical explanations that only served to further cloud the issue, but thanks to LYAH I finally got it.
In short, he has you using monads long before you understand them (Maybe and IO in particular), then slowly introduces monads by first explaining functors and applicative functors.
In retrospect, the mystique seems crazy. Monads are just not that confusing: they're simply values with added context, along with functions that let you interact with those values without losing the context. It's a shame that this powerful idea is so obscured by its supposed difficulty.
- deleted 16y ago[deleted]
- runT1ME 16y ago>Monads are just not that confusing I don't think the 'what' is confusing, but the 'why and when'. Monads are a pattern; when I first learned about the Strategy Pattern, I understood it. It wasn't until a while later I started seeing the need for it and could explain why...
- axod 16y agoAnalyzing code and naming patterns is far harder than just writing and reading code. Also it's kinda pointless. If you go up to an improvising musician and tell them how amazing the hemiola cadence they just used was, they'd probably tell you to chill out and enjoy the music.
- raganwald 16y agoMy bass teacher used to say: "Music theory is not music. It's just a way we have of talking about music."
- axod 16y agoUnfortunately I took Music 'A' Level at school (age 16-18). It was pretty much all music theory - history of composers, analyzing music, etc. Pretty much no playing music at all. Boring as hell.
- jhpriestley 16y ago`(a->r)->r` is `a` with some added context?
- tel 16y agoIn the sense that you can combine Cont r a objects into CPS computations over a value of type a, yes. It's a leaky metaphor but it does reiterate the two levels of logic going on in a monad: the "boxed" value and the "box" itself.
- vegai 16y ago>Monads are just not that confusing: they're simply values with added context, along with functions that let you interact with those values without losing the context. It's a shame that this powerful idea is so obscured by its supposed difficulty. This is a typical thing in mathematics.
- sesqu 16y agoThis is why I don't like self-study for mathematics. A lot of the stuff is very simple once you understand what it's for, but finding out what it's for from the formal definition is an uphill battle. And then, after you see the thing for what it is (months later), you start coming up with questions that lead to more formalism. Studying from an encyclopaedia is hard, and even a good book will only get you as far as well-known results. Answers are much easier to learn from, so you want someone to provide you with the correct questions and avoid the difficult ones.