-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6363fbb
commit fc36643
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
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
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; | ||
} |