Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upA simple try for HKT #40368
A simple try for HKT #40368
Conversation
|
Cool! Could you fix the test cases(or lint or merge master) and we could pack this. |
|
Alright, finally...... |
|
seems not work again.... |
|
Oh, I see the cute little green check mark and would not push any more until it is packed this time |
|
@typescript-bot pack this. |
|
Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
|
Soo coooooooooooooooooooooooool! |
|
Excited! |
|
@ShuiRuTian Really excited about this feature. But if I am not mistaken it seems like it doesn't work for types only interfaces. So we can't create a sum type like: |
|
@lupuszr |
|
@typescript-bot pack this. |
|
lol, only TS team member could do that. |
|
Sorry I hoped I have magic powers like that :D Anyway what I tested in the last playground was: In the playground this was my test: interface Just<A> {value: A, tag: 'Maybe/Just'};
interface Nothing { tag: 'Maybe/Nothing'};
type Maybe<A> = Just<A> | Nothing;
type Functor<F<_>> = {
map: <A, B>(f: (a: A) => B) => ((fa: F<A>) => F<B>)
}
type Monad<F<_>> = {
bind: <A, B>(f: (a: A) => F<B>) => ((fa: F<A>) => F<B>)
}
type L = Functor<Maybe>;and got an error Generic type 'Maybe' requires 1 type argument(s).(2314) the same happens for:
Is this handled by your last commit ? |
|
Not sure, would check when having time. My break time is nearly at an end. |
|
@lupuszr Auh, it should work for the sample code now. But I do not fix error and the code is really ugly..... |
|
@typescript-bot pack this |
Fixes #1213
Far from complemention, just a try for now.
Backlog for myself
These are not definition, but a simple explaination, for myself.
proper type: a specific type, like number,Array<number>.Array<T>is not, because T is not specific.type constructor: interface/class accept generic, like Array which accepts 1 and Map which accepts 2. When used in the rest part, often indicate it is a type parameter too.type parameter: in the declaration, the generic. Like K,V inMap<K,V>type arguments: generic when use generic class, like number inArray<number>Two list, one is added ability, one is added error check.
Ability
// from communicity
Error
Some details.
(1)
(2)
(3)
(4)
we could see that Generic has declaration(2) and instance(3).
Similarly, after (1), we need to distinuish declaration and instance, like 1.1 and 1.2
Generic could already accept constraint, maybe I could add new abstract to use it? As we could see, they are similar in some degrees.