I may be misunderstanding you, but from your description, that more describes functors than it does monads. The difference being that in a monad, the `someFunc` you pass in is responsible for creating a new context (of the same monad type).
Pretending that javascript is immutable, I think it would probably look something more like
contextObj = monadBox(myObj)
// someContextReturningFunc gets myObj as its argument from contextObj and generates newContextObj
newContextObj = monadBind(contextObj, someContextReturningFunc)
newNewContextObj = monadBind(newContextObj, someOtherContextReturningFunc)
...
To make this more concrete, let's take the Maybe monad/functor in javascript and compare them. The Maybe monad is described by johnpmayer elsewhere here.
// Creating maybe "contexts"
maybeNothing = {maybe: "nothing"}; // maybeMonad holding nothing
maybeJust = function(x) { return {maybe: "just", just: x} }; // create a maybeMonad holding a (the '[a]' in the picture)
// Monadic bind
function maybeBind(maybeMonad, f) {
// maybeMonad is '[a]' in the picture
if (maybeMonad.maybe === "just") {
return f(maybeMonad.just); // expects f to return another maybeMonad '[b]'
} else {
return maybeNothing; // also '[b]' but the b value doesn't really exist
}
}
// Functor map
function maybeMap(maybeMonad, f) {
// maybeMonad is '[a]' in the picture
if (maybeMonad.maybe === "just") {
return maybeJust(f(maybeMonad.just)); // expects f to return a value without any maybe stuff ('a -> b')
// notice that the monad wrapping remains separate from f
} else {
return maybeNothing;
}
}
// Functor examples
//////
// possible values of 'f', note that maybe is not involved at all
function addOne(x) { return x + 1; }
// usage
console.log(maybeMap(maybeJust(1), addOne)); // returns maybeJust(2)
console.log(maybeMap(maybeNothing, addOne)); // returns maybeNothing
// Monad examples
//////
// possible values for 'f', notice x is what was contained in the maybe (not the maybe itself) and the return is a maybe
function maybeAddOneIfOdd(x) { return (x % 2 == 0) ? maybeNothing : maybeJust(x + 1); };
function maybeAddThree(x) { return maybeJust(x + 3); };
// usage
console.log(maybeBind(maybeJust(1), maybeAddThree)); // returns maybeJust(4)
console.log(maybeBind(maybeJust(1), maybeAddOneIfOdd)); // returns maybeJust(2)
console.log(maybeBind(maybeBind(maybeJust(1), maybeAddThree), maybeAddOneIfOdd)); // returns maybeNothing (due to 4 being even)
console.log(maybeBind(maybeBind(maybeJust(2), maybeAddOneIfOdd), maybeAddThree)); // returns maybeNothing because the first bind returned nothing
// and of course, composition
function maybeMultiplyThree(x) { return maybeJust(x * 3); }
function maybeMultiplyThreeThenAddOneIfOdd(x) {
return maybeBind(maybeMultiplyThree(x), maybeAddOneIfOdd);
}
console.log(maybeBind(maybeJust(1), maybeMultiplyThreeThenAddOneIfOdd)); // returns maybeJust(4)
console.log(maybeBind(maybeJust(2), maybeMultiplyThreeThenAddOneIfOdd)); // returns maybeNothing
For more specifics into the cognitive science behind why this is - another good book, which has lots of wonderful references to studies on this topic (amongst other things), is "Your Brain at Work" by David Rock. Or, for the general overview you can watch the Google Talk at http://www.youtube.com/watch?v=XeJSXfXep4M
Sanjoy Mahajan, the author of this article, is the Associate Director at the Teaching and Learning Laboratory @ MIT. If you're interested in education, he has an excellent OCW course [1] where you can hear more about his techniques for teaching.
I don't know if I'm misinterpreting Derek Muller, but I didn't get the impression that people had to be confused/overwhelmed to learn. I think it's only necessary when there's incorrect prior knowledge.
If interested, here's my take/rant about it:
I believe that prior knowledge and misconceptions can change how people deal and interpret new information. This can help or it can hurt the learning process.
It can help because it often makes new knowledge more likely to "stick." For example, a soccer fan is more likely to remember soccer scores [1]. I know there's other research that indicate more prior knowledge leads to quicker learning, but I don't remember them off the top of my head.
It can hurt in much of the same ways Derek Muller describes. When hearing new information it can easily be misinterpreted to match current knowledge. For example, anecdotally, those only familiar with the words "negative" (bad) and "reinforcement" (adding/reaffirming) are more likely to misinterpret "negative reinforcement" to mean "punishing behavior by adding something bad" instead of "rewarding behavior by taking something bad away." I believe there were similar findings/studies within statistics. Another common one is F=mv as shown in Muller's videos. I'm sure there are plenty more examples.
I believe Derek Muller's problem with Khan's videos is that they might not challenge incorrect previous knowledge. I agree with Muller and personally feel that Khan Academy will likely encounter some of these same problems when students watch the videos.
But, I also believe that the other half of Khan Academy (exercises) provide feedback that videos alone otherwise do not have. I believe that the requirement for mastery through the exercises can and will challenge at least some of these misconceptions. Particularly if the questions are good questions.
I also believe that Khan Academy is going to find themselves in a position where they can potentially have a lot of interesting data. I'd love to be able to see whether they can use this data to find some of these common misconceptions and then improve videos and/or questions. In the very least, I believe that their exercises will serve as a good metric to see where misconceptions are being poorly addressed.
We also have to keep in mind that, at least in the pilot in Los Altos school district, these videos are not the only source where students are learning. They still have time with teachers where these misconceptions can be addressed. In addition to that, they'll have the opportunity to review the videos to contrast, reflect on what lead to the misunderstanding, and hopefully reaffirm the new knowledge.
tldr - I believe Khan Academy's exercises and class/teacher time might help deal with the issue of misconceptions.