Created
April 10, 2011 19:17
-
-
Save bmaddy/912632 to your computer and use it in GitHub Desktop.
Continuation monad in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function M(){}; | |
M.contResult = function(value){ | |
return function(cont){ | |
console.log('in result: ' + value); | |
return cont(value); | |
} | |
} | |
M.contBind = function(mValue, mFunc){ | |
return function(cont){ | |
return mValue(function(value){ | |
return mFunc(value)(cont); | |
}); | |
} | |
} | |
M.identity = function(x){ return x; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment