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

Function type generalization #7

Open
girving opened this issue Jul 18, 2009 · 0 comments
Open

Function type generalization #7

girving opened this issue Jul 18, 2009 · 0 comments
Labels

Comments

@girving
Copy link
Owner

girving commented Jul 18, 2009

If we apply a higher order function like "map" to an overloaded closure like negate and an int list, the type inference algorithm currently infers a type like

map :: negate -> [Int] -> [Int]

This means that if you apply map to a different function, like square, it infers a separate judgement

map :: square -> [Int] -> [Int]

This can be serious performance hit, causing degradation by factors of up to infinity. It would be much better to notice that in each case map only applies the closure to arguments of a single type, and infer the generalization

map :: (Int -> Int) -> [Int] -> [Int]

Note that this almost happens automatically if "map" has a standard type signature.

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

No branches or pull requests

1 participant