Skip to content

Instantly share code, notes, and snippets.

View jgnewman's full-sized avatar

John Newman jgnewman

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jgnewman on github.
  • I am jgnewman (https://keybase.io/jgnewman) on keybase.
  • I have a public key whose fingerprint is AC4B B9C2 BB6E B063 1D51 57DD A1BD 62D8 DEDB B15C

To claim this, I am signing this object:

@jgnewman
jgnewman / gist:4121035
Created November 20, 2012 20:55
Monads in JavaScript

Here's a quick proof of concept for generating monads in JavaScript:

First, the way you'd call it...

var monad = new Monad();

monad.pass(1).to(function (x) {var y = x + 1; console.log(y); return y;},
                 function (x) {var y = x + 2; console.log(y); return y;},
                 function (x) {var y = x + 3; console.log(y); return y;});
// So you would have a language that you created...
def myfunction: [param1 param2] ->
somefunction(param1 param2);
end
// in order to turn that into javascript or anything else,
// you need a compiler. if you ever try to write a compiler,
// you'll learn very quickly that it will kill you and eat
// you if you're not careful. the best way to keep your