This file contains 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 noop() { /* nothing */} | |
interface Unsubscribable { | |
unsubscribe(): void; | |
} | |
interface Subscription extends Unsubscribable { | |
unsubscribe(): void | |
} |
This file contains 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
interface Functor<A> { | |
fmap<B>(fn: (a: A) => B): Functor<B> | |
} | |
abstract class Applicative<A> implements Functor<A> { | |
static of: <A>(a: A) => Applicative<A>; | |
abstract fmap<B>(fn: (a: A) => B): Applicative<B>; | |
abstract ap<B, C>(this: Applicative<(b: B) => C>, ma: Applicative<B>): Applicative<C>; | |
lift<B, C>(fn: (a: A, b: B) => C) : (mb: Applicative<B>) => Applicative<C> { |
This file contains 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 wrap(iterator) { | |
const sequence = []; | |
const next = (i) => { | |
if (sequence.length > i) { | |
return { | |
value: sequence[i], | |
done: false | |
} | |
} |
This file contains 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
{-# LANGUAGE RankNTypes #-} | |
module Main where | |
import Prelude hiding (Monad(..), Monoid(..)) | |
-- class Monoid m where | |
-- mempty :: m | |
-- mappend :: m -> m -> m | |
-- mconcat :: [m] -> m | |
-- mconcat = foldr mappend mempty |
This file contains 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
{-# LANGUAGE RankNTypes, TypeOperators #-} | |
module Main where | |
import Prelude as P | |
data Free f a | |
= Pure a | |
| Free (f (Free f a)) | |
instance Functor f => Functor (Free f) where | |
fmap f (Pure a) = Pure $ f a |
This file contains 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
new Promise((resolve, reject) => { | |
reject(false); | |
}).then(() => {}, (error) => { | |
console.log('error handle') | |
}).catch(error => { | |
console.log('catch') | |
}) | |
// => error handle |
This file contains 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
const slice = Array.prototype.slice; | |
const isGenerator = (obj) => { | |
return 'function' == typeof obj.next && 'function' == typeof obj.throw; | |
} | |
function isPromise(obj = {}) { | |
return 'function' == typeof obj.then; | |
} |
This file contains 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
#!/bin/bash |
This file contains 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
const Y = function(F) { | |
return (function (h) { | |
return h(h) | |
})(function(h) { | |
return F(function() { | |
return h(h).apply(this, arguments) | |
}) | |
}) | |
} |
This file contains 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
#!/bin/bash | |
files=`find ./src -type f -regex "./.*.[^coffee]"` | |
for file in $files | |
do | |
path=`dirname $file` | |
newpath=`echo ${path//src/build}` | |
filename=`basename $file` | |
if [ ! -d $newpath ]; then |