Skip to content
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

Open
rpominov opened this issue Mar 22, 2016 · 15 comments
Open

Flow/TypeScript #4

rpominov opened this issue Mar 22, 2016 · 15 comments

Comments

@rpominov
Copy link
Member

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

@rpominov
Copy link
Member Author

@rpominov rpominov self-assigned this Jun 4, 2016
@rpominov
Copy link
Member Author

rpominov commented Jun 9, 2016

Might be related: facebook/flow#30

@rpominov rpominov removed their assignment Aug 12, 2016
@dead-claudia
Copy link
Contributor

@gcanti
Copy link

gcanti commented Aug 14, 2016

@rpominov I wrote a POC for Flow here

@rpominov
Copy link
Member Author

@gcanti I'll need to look closer at it, but seems that you've solved problem with higher kinded types using the HKT helper. That's great!

@rpominov
Copy link
Member Author

@gcanti Is flow-static-land more like an experiment or something that can be used in production? Asking because maybe we should add it to the list https://github.com/rpominov/static-land/wiki/Compatible-libraries

@gcanti
Copy link

gcanti commented Aug 23, 2016

@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.

@rpominov
Copy link
Member Author

Great, sounds like it have potential to become useful in production. I'll add to the list.

@laurence-myers
Copy link

Do you think the same HKT technique would work for TypeScript?

@dead-claudia
Copy link
Contributor

@laurence-myers Yes, but due to TypeScript's lack of nominal typing, it'd remove all type safety from it.

@gcanti
Copy link

gcanti commented Nov 20, 2016

@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))
}
@gcanti
Copy link

gcanti commented Nov 20, 2016

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 HKT abstraction?

@rpominov
Copy link
Member Author

I heard type inference is much more limited in TypeScript, don't know much about it though.

@gcanti
Copy link

gcanti commented Feb 17, 2017

@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)

@rpominov
Copy link
Member Author

That's great, @gcanti ! Thank you for doing all this research!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants