Permalink
Browse files

value

  • Loading branch information...
1 parent 689d608 commit 0f922ebe6d1645d3b448510cfb664d003616f0bf Douglas Crockford committed Jan 26, 2013
Showing with 6 additions and 4 deletions.
  1. +6 −4 monad.js
View
@@ -1,6 +1,6 @@
// monad.js
// Douglas Crockford
-// 2012-10-17
+// 2013-01-26
// Public Domain
@@ -30,16 +30,18 @@
// monad.bind = function () {
// return monad;
// };
+// return null;
// }
+// return value;
// });
// var monad = maybe(null);
-// monad.bind(alert);
+// monad.bind(alert); // Nothing happens.
function MONAD(modifier) {
'use strict';
// Each unit constructor has a monad prototype. The prototype will contain an
-// is_monad property for classification, as well as all inherited methods.
+// is_monad property for classification, as well as all inheritable methods.
var prototype = Object.create(null);
prototype.is_monad = true;
@@ -74,7 +76,7 @@ function MONAD(modifier) {
// and the value.
if (typeof modifier === 'function') {
- modifier(monad, value);
+ value = modifier(monad, value);
}
// Return the shiny new monad.

0 comments on commit 0f922eb

Please sign in to comment.