Skip to content

Instantly share code, notes, and snippets.

@co1rowjp
co1rowjp / gist:4264876
Created December 12, 2012 04:30
typescript. I want's to write pattern match....
interface Matcher {
caseA (any): any;
caseB (any): any;
caseAny (any): any;
}
class Parent {
data: any;
constructor (data: any) {
this.data = data
}
@co1rowjp
co1rowjp / gist:4252025
Created December 10, 2012 17:33
TypeScript Maybe(I want pattern match..)
interface Functor {
fmap: (any) => any;
}
interface Monad extends Functor {
bind: (any) => Monad;
}
interface MaybeMatcher {
just: (any) => Maybe;
@co1rowjp
co1rowjp / gist:3849125
Created October 7, 2012 18:13
Typescript Either
interface Either {
isRight: Boolean;
isLeft: Boolean;
left: LeftProjection;
right: RightProjection;
}
class Right implements Either {
isRight: Boolean = true;
isLeft: Boolean = false;
@co1rowjp
co1rowjp / gist:3845888
Created October 6, 2012 19:39
TypeScript Maybe
interface Functor {
fmap: (any) => any;
}
interface Monad extends Functor {
bind: (any) => Monad;
}
interface Maybe extends Monad {
}