From fc36643f0fcff24580e1c29d0582d7f3e941eb2d Mon Sep 17 00:00:00 2001 From: Nicolas Zozol Date: Fri, 13 Oct 2017 06:29:42 +0200 Subject: [PATCH] #88: Starting typescript support --- integration-ts/masala.d.ts | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 integration-ts/masala.d.ts diff --git a/integration-ts/masala.d.ts b/integration-ts/masala.d.ts new file mode 100644 index 0000000..470101d --- /dev/null +++ b/integration-ts/masala.d.ts @@ -0,0 +1,68 @@ +// Not needed +export interface Option{ + isPresent():boolean; + map( bindCall: ()=>any ):any; + flatmap (bindCall: ()=>any): Type; + filter (f :(value:Type)=>boolean):Type|Option + get(): Type + orElse(v:X): Type|X; + orLazyElse(v:X): Type|X; + +} + +export interface Try{ + isSuccess(): boolean; + isFailure(): boolean; + onSuccess(f : ()=>any):Try; + onFailure(f : ()=>any):Try; + map( bindCall: ()=>any ):Try; + flatmap (bindCall: ()=>any): Try; + success():V; + failure():E; + recoverWith(X):V|X; + lazyRecoverWith(X):V|X; + filter(f :(value:V)=>boolean):Try + +} +// Not needed +export interface List{ + size:number; + isEmpty: boolean; + array: Array +} + +export interface Stream{ + location(index:number):number; + get():Data; + subStreamAt(index:number, stream:Stream) + +} + +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, index:number):Response; +} + +export interface Response{ + isAccepted():boolean + fold(accept, reject?):Response; + map(f):Response; + flatmap(f):Response; + filter(f:(value)=>boolean):Response; +} \ No newline at end of file