UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

12 lines (11 loc) 674 B
import { Mappable } from "./types"; type TMultiMethod<A, B> = A extends any[] ? (...args: A) => B : Mappable<A, B>; export interface MultiMethod<ArgList extends any[], B> { (...args: ArgList): B; } export declare class MultiMethod<ArgList extends any[], B> extends Function { constructor(dispatch: TMultiMethod<ArgList, any>); } export declare function defmulti<Input extends any | any[], Result>(dispatch: TMultiMethod<Input, any>): MultiMethod<Input extends any[] ? Input : [Input], Result>; export declare function defmethod<M extends MultiMethod<any, any>>(multimethod: M, dispatchResult: any, impl: TMultiMethod<Parameters<M>, ReturnType<M>>): void; export {};