拥有这个:
type Format<A, R> = (arg: A) => R;
type FormatString<R> = (str: string) => R;
type FormatNumber<R> = (num: number) => R;
想要这个:
type Format<A<R>> = (arg: A) => R;
type FormatString = Format<string>;
type FormatNumber = Format<number>;
或者这个:
type Format<A, R> = (arg: A) => R;
type FormatString = Format<string>;
type FormatNumber = Format<number>;
我正在寻找针对类型的Curry或部分应用程序。也许还有其他解决方法可以使代码保持干燥。
答案 0 :(得分:3)
只需在部分专用类型上将R添加为另一个类型参数。
type Format<A, R> = (arg: A) => R;
type FormatString<R> = Format<string, R>;
type FormatNumber<R> = Format<number, R>;