Implementing Monads in JavaScript
UPDATE: This post has been updated to a new post. All the code has been refactored and redone in the new post. http://functionaljavascript.blogspot.in/2013/07/monads.html Consider the problem of doing a series of computations (calling a series of functions), and you want each successive computation to have access to the results of the previous computations. We will write a function called doComputations , and here is how a call to doComputations would look like. var result = doComputations( "a", function(scope) { return 2; }, "b", function(scope) { with (scope) { return a * 3; } }, function(scope) { with(scope) { return a + b; } } ); The arguments to doComputaions are one or more "string - function" pairs and the last argument is just a "result" function. The string is a variable name which will be assigned the value returne...