UNPKG

decline-ts

Version:

Composable command-line parser for TypeScript - a (partial) porting of Scala decline using fp-ts

38 lines (37 loc) 1.31 kB
import { functor } from 'fp-ts'; import { Lazy } from 'fp-ts/function'; declare const URI = "Match"; declare type URI = typeof URI; declare module 'fp-ts/HKT' { interface URItoKind<A> { readonly [URI]: Match<A>; } } export declare type Match<A> = MatchFlag<A> | MatchOption<A> | MatchAmbiguous; export declare type MatchFlag<A> = { readonly _tag: 'MatchFlag'; readonly next: A; }; export declare type MatchOption<A> = { readonly _tag: 'MatchOption'; readonly next: (str: string) => A; }; export declare type MatchAmbiguous = { readonly _tag: 'MatchAmbiguous'; }; declare type FoldArgs<A, B> = { readonly onFlag: (a: A) => B; readonly onOption: (next: (str: string) => A) => B; readonly onAmbiguous: Lazy<B>; }; export declare const Match: { fold: <A, B>({ onFlag, onOption, onAmbiguous }: FoldArgs<A, B>) => (fa: Match<A>) => B; isMatchFlag: <A_1>(match: Match<A_1>) => match is MatchFlag<A_1>; isMatchOption: <A_2>(match: Match<A_2>) => match is MatchOption<A_2>; map: <A_3, B_1>(f: (a: A_3) => B_1) => (fa: Match<A_3>) => Match<B_1>; match: functor.Functor1<"Match">; matchAmbiguous: MatchAmbiguous; matchFlag: <A_4>(next: A_4) => MatchFlag<A_4>; matchOption: <A_5>(next: (str: string) => A_5) => MatchOption<A_5>; }; export {};