Skip to content

Hindley–Milner style declarations would improve readability a lot #17926

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

Closed
rlopes opened this issue Aug 19, 2017 · 3 comments
Closed

Hindley–Milner style declarations would improve readability a lot #17926

rlopes opened this issue Aug 19, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@rlopes
Copy link

rlopes commented Aug 19, 2017

It is just a general suggestion and one thing I really appreciate with some FP languages like Haskell is this separation between declaration and implementation.

Types tend to add a cognitive load, a lot of noise around code and it would be a real killer feature if we could use Hindley–Milner style declarations. This would improve readability of the functions while providing type safety.

@aluanhaddad
Copy link
Contributor

aluanhaddad commented Aug 19, 2017

If you are proposing introducing actual syntax from Haskell directly into TypeScript, I think that will be a hard sell.

It is fairly easy separate declarations and definitions currently

export interface User {name: string; password: string;}

export type Login = (user: User) => Promise<boolean>;

export const login: Login = user => Promise.resolve(true);

export const user: User = {name: 'Robert', id: 0};

login(user);

@DanielRosenwasser DanielRosenwasser added Out of Scope This idea sits outside of the TypeScript language design constraints Duplicate An existing issue was already created and removed Out of Scope This idea sits outside of the TypeScript language design constraints labels Aug 19, 2017
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Aug 19, 2017

Duplicate of #11218.

@rlopes
Copy link
Author

rlopes commented Aug 19, 2017

Correct I am talking about the very same thing found in #11218. This one can be closed for the benefit of the other containing a good explanation. Thanks for answering.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants