Skip to content

Instantly share code, notes, and snippets.

View puffnfresh's full-sized avatar

Brian McKenna puffnfresh

View GitHub Profile
import language.implicitConversions
class AmbiguousStringAdd {
def +(b: String) = ???
}
implicit def amb1any2stringadd(a: Any) = new AmbiguousStringAdd
implicit def amb2any2stringadd(a: Any) = new AmbiguousStringAdd
class A {}
let arrayMonad = {
return: \x -> [x]
bind: \x f -> Array.prototype.concat.apply [] (x.map f)
}
let array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
console.log (do arrayMonad
x <- array
y <- array
@puffnfresh
puffnfresh / Option.js
Created May 29, 2012 04:41 — forked from jaredbc/Option.js
JS option
function some(a) {
return {
fold: function(f, _) {
return f(a);
},
getOrElse: function(e) {
return a;
},
orElse: function() {
return some(a);