... | ... | @@ -74,7 +74,7 @@ test2 = foo . bar |
|
|
```
|
|
|
|
|
|
|
|
|
Should `test1` typecheck? Yes: GHC can see that `foo`'s argument should have type `forall a. a->a`, and indeed `bar x` has that type. It involves higher-rank type inference (see [ Practical type inference for higher rank types](http://research.microsoft.com/en-us/um/people/simonpj/papers/higher-rank/index.htm)), but GHC has supported this for ages.
|
|
|
Should `test1` typecheck? Yes: GHC can see that `foo`'s argument should have type `forall a. a->a`, and indeed `bar x` has that type. It involves higher-rank type inference (see [Practical type inference for higher rank types](http://research.microsoft.com/en-us/um/people/simonpj/papers/higher-rank/index.htm)), but GHC has supported this for ages.
|
|
|
|
|
|
|
|
|
What about `test2`? After all, it's just an eta-abstracted version of `test1`. No, `test2` is rejected. Remember the type of `(.)`:
|
... | ... | @@ -157,10 +157,10 @@ Now `[ListList]` is a perfectly fine type. The downside is that you have to wra |
|
|
Here are some useful papers about type inference for impredicative polymorphism;
|
|
|
|
|
|
|
|
|
- [ FPH : First-class Polymorphism for Haskell (2008)](http://research.microsoft.com/en-us/um/people/simonpj/papers/boxy/)
|
|
|
- [ Boxy types: type inference for higher rank and impredicativity (2006)](http://research.microsoft.com/en-us/um/people/simonpj/papers/boxy/) We implemented this in GHC, but it was Just Too Complicated.
|
|
|
- [ QML: Explicit first-class polymorphism for ML (2009)](http://research.microsoft.com/en-us/um/people/crusso/qml/) A much simpler, and less ambitious, approach.
|
|
|
- [ MLF: Raising ML to the power of System F (2003)](http://gallium.inria.fr/~remy/publications.html) The other end of the spectrum from QML: a very sophisticated approach.
|
|
|
- [FPH : First-class Polymorphism for Haskell (2008)](http://research.microsoft.com/en-us/um/people/simonpj/papers/boxy/)
|
|
|
- [Boxy types: type inference for higher rank and impredicativity (2006)](http://research.microsoft.com/en-us/um/people/simonpj/papers/boxy/) We implemented this in GHC, but it was Just Too Complicated.
|
|
|
- [QML: Explicit first-class polymorphism for ML (2009)](http://research.microsoft.com/en-us/um/people/crusso/qml/) A much simpler, and less ambitious, approach.
|
|
|
- [MLF: Raising ML to the power of System F (2003)](http://gallium.inria.fr/~remy/publications.html) The other end of the spectrum from QML: a very sophisticated approach.
|
|
|
|
|
|
### The way forward
|
|
|
|
... | ... | |