Skip to content

Commit

Permalink
#88: Starting typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-zozol committed Oct 15, 2017
1 parent 6363fbb commit fc36643
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions integration-ts/masala.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Not needed
export interface Option<Type>{
isPresent():boolean;
map( bindCall: ()=>any ):any;
flatmap (bindCall: ()=>any): Type;
filter (f :(value:Type)=>boolean):Type|Option<Type>
get(): Type
orElse<X>(v:X): Type|X;
orLazyElse<X>(v:X): Type|X;

}

export interface Try<V,E>{
isSuccess(): boolean;
isFailure(): boolean;
onSuccess(f : ()=>any):Try<V,E>;
onFailure(f : ()=>any):Try<V,E>;
map( bindCall: ()=>any ):Try<V,E>;
flatmap (bindCall: ()=>any): Try<V,E>;
success():V;
failure():E;
recoverWith<X>(X):V|X;
lazyRecoverWith<X>(X):V|X;
filter(f :(value:V)=>boolean):Try<V,E>

}
// Not needed
export interface List<E>{
size:number;
isEmpty: boolean;
array: Array<E>
}

export interface Stream<Data>{
location(index:number):number;
get():Data;
subStreamAt(index:number, stream:Stream<Data>)

}

export interface Parser{
flatmap (f: ()=>any): Parser;
map (f: ()=>any): Parser;
filter(f :()=>boolean):Parser
match(value:any):Parser;
then(p:Parser):Parser;
concat: Parser;
drop:Parser;
thenLeft: Parser;
thenRight:Parser;
thenReturns(value:any): Parser;
or(p:Parser):Parser;
opt():Parser;
rep():Parser;
occurrence(n:number):Parser;
optrep():Parser;
chain():Parser;
debug(hint?:string, details?:boolean);
parse(stream:Stream<any>, index:number):Response;
}

export interface Response{
isAccepted():boolean
fold(accept, reject?):Response;
map(f):Response;
flatmap(f):Response;
filter(f:(value)=>boolean):Response;
}

0 comments on commit fc36643

Please sign in to comment.