Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create Monad.js

  • Loading branch information...
commit 4773ab5f243f81ea6568a7eb0fe7499efd178adc 1 parent ad3c78d
@kentaromiura authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 Monad.js
View
11 Monad.js
@@ -0,0 +1,11 @@
+function Monad(value){
+ if (value instanceof Monad) return value
+ this.value = function(){return value}
+}
+
+Monad.prototype.bind = function(f){
+ var value = this.value()
+ if (f === Monad || value === null || value === undefined) return this
+ return new Monad(f(value))
+ return this
+}
Please sign in to comment.
Something went wrong with that request. Please try again.