Reputation: 496
This probleme is describe in this issue: Microsoft/TypeScript/#1213...
I am trying to implement the Chain specification:
(I need to pass a type to the
ApType
so that on line 12 (in the snippet below) theApply
is not hard coded but generic to also take types extended from anyIApply
)
m['fantasy-land/chain'](f)
A value that implements the Chain specification must also implement the Apply specification.
a['fantasy-land/ap'](b)
I did a FunctorSimplex
which is then extended by a FunctorComplex
then extended by the Apply
but now that I want to extend Apply
as a Chain
it is breaking...
So I need that (image below and link to code):
Permalink to the code snippet lines 11 to 22 in 7ff8b9c
export type ApType<A = unknown> = <B = unknown>(
ap: Apply<(val: A) => B>,
) => IApply<B>;
/* [...] */
export interface IApply<A = unknown> extends FunctorComplex<A> {
/** `Fantasy-land/ap :: Apply f => f a ~> f (a -> b) -> f b` */
ap: ApType<A>;
}
Upvotes: 0
Views: 126
Reputation: 2182
I think what you are looking for is higher kinded type (HKT). In Typescript, HKT can be achieved using something called as module augmentation
. Check this article. You can refer fp-ts implementations too.
Upvotes: 1