What I Wish I Knew When Learning Haskell
I disagree completely with his analysis on monads.<p>If you just present the abstract structure, you cannot understand <i>why</i> you even want (for example) the do notation as a language-level concept. I think this is more of a case of bad examples than anything.<p>Trying to represnent monads via analogy works badly too though, because monads as used in haskell are more about programming pragmatics than modelling real world objects.<p>The way to explain it should be :<p>- Show real code<p>- Explain why we use this structure to write our code .I think a good explanation is to ...<p>in Jquery you do things like chaining to build things.<p>$('selector').css('color','red').filter(someFilter).css('color','blue')<p>Chaining APIs are useful because you're combining computation('chaining'), and you don't want to have to carry around a value everywhere. You want to do the same thing in Haskell obviously.<p>Haskell doesn't have dot notation, so you can't do this style exactly. First idea would be to do something like<p>let x=jQuery document selector in 
let y=css x 'color' 'red' in 
let z=filter y someFilter in
...<p>This is a pain, especially considering that the 'chaining' here is mechanically obvious<p>let [n+1] = f [n] [whatever] in 
let [n+2] = g [n+1] ....<p>So monads, in the most pragmatic sense, allow you to represnt this form of computation. You end up with<p>jQuery 'selector' 
>>= css 'color' 'red'
>>= filter someSelector 
>>= css 'color' blue'<p>You implicitly carry around your computation.<p>)<p>In any case the Maybe monad is the worst example ever, just like how a singleton group is a bad example. Sure it's the 'simplest' , but it's far from the most typical