Skip to content

Proposal: specialize a polymorphic function by providing type argument(s) only #19818

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
pelotom opened this issue Nov 7, 2017 · 3 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@pelotom
Copy link

pelotom commented Nov 7, 2017

If you have a polymorphic function, it would be nice to be able to specialize it by just providing type argument(s):

declare const identity: <A>(x: A) => A;

const numId: identity<number>;
// numId: (x: number) => number

You can accomplish this in most (all?) cases by assigning to a variable of the appropriate type

declare const identity: <A>(x: A) => A;

const numId: (x: number) => number = identity;

but the type on the LHS may end up being arbitrarily larger than the simple input type you could've provided on the RHS.

@pelotom pelotom changed the title Proposal: specialize a polymorphic function by providing type parameter(s) only Proposal: specialize a polymorphic function by providing type argument(s) only Nov 7, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Nov 7, 2017

seems like the same as #15877

@mhegazy mhegazy added the Duplicate An existing issue was already created label Nov 7, 2017
@pelotom
Copy link
Author

pelotom commented Nov 7, 2017

@mhegazy as usual @mhegazy is the most effective search engine for duplicates 😜 Seriously though, I promise I'm looking for existing issues first!

@pelotom pelotom closed this as completed Nov 7, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Nov 7, 2017

github search is not really helpful.. you need to know what you are looking for in most cases.. it is just that i do this more often :D

@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

2 participants