-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow/TypeScript #4
Comments
Related: fantasyland/fantasy-land#140 |
Might be related: facebook/flow#30 |
@rpominov I think microsoft/TypeScript#1213 and microsoft/TypeScript#7848 are equally as related as facebook/flow#30. |
@gcanti I'll need to look closer at it, but seems that you've solved problem with higher kinded types using the |
@gcanti Is |
@rpominov I'd say that now is more than an experiment. I'm working on it full time and seems really promising. In the last few days I ported some PureScript libraries and it's quite straightforward. I don't think is production ready though: tests are missing and there are some issues that must be solved, first of all how to publish / distribute the code (not yet sure what's the blessed way, shadow files? libdef? raw sources like now?). Also, I'd like to apply what I wrote so far to a real world case: I just started porting the QuickCheck library. If succesful it would be a nice proof that it can be used for "real" development. |
Great, sounds like it have potential to become useful in production. I'll add to the list. |
Do you think the same HKT technique would work for TypeScript? |
@laurence-myers Yes, but due to TypeScript's lack of nominal typing, it'd remove all type safety from it. |
@isiahmeadows I'm just learning TypeScript but what about something like this? // Functor.js
type HKT<F, A> = { type: 'HKT', F: F, A: A };
export interface Functor<F> {
map<A, B>(f: (a: A) => B, fa: HKT<F, A>): HKT<F, B>
}
// Arr.js
export type Arr<A> = HKT<'Arr', A>;
export function inj<A>(a: Array<A>): Arr<A> {
return a as any as Arr<A>
}
export function prj<A>(fa: Arr<A>): Array<A> {
return fa as any as Array<A>
}
export function map<A, B>(f: (a: A) => B, fa: Arr<A>): Arr<B> {
return inj(prj(fa).map(f))
} |
Just pushed a proof of concept here: https://github.com/gcanti/ts-static-land. Though I'm not sure why sometimes I have to specify so many type parameters, for example here https://github.com/gcanti/ts-static-land/blob/master/src/Identity.ts#L67 or here https://github.com/gcanti/ts-static-land/blob/master/src/Maybe.ts#L118 Isn't TypeScript able to infer those types? Or is there a deeper problem in my code or with the |
I heard type inference is much more limited in TypeScript, don't know much about it though. |
@rpominov FYI I'm working on https://github.com/gcanti/fp-ts (TypeScript) which supersedes my previous attempt. One of the main goals is to be compatible with both fantasy-land and static-land (hopefully) |
That's great, @gcanti ! Thank you for doing all this research! |
I have no idea what can be done in this area yet, but wanted to open an issue for general discussion on the topic.
Some relevant links:
https://github.com/donnut/typescript-ramda/
facebook/flow#172
The text was updated successfully, but these errors were encountered: