Skip to content

Instantly share code, notes, and snippets.

@bmaddy
Created April 10, 2011 19:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bmaddy/912632 to your computer and use it in GitHub Desktop.
Save bmaddy/912632 to your computer and use it in GitHub Desktop.
Continuation monad in javascript
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