GHC type inference for higher rank types - assigning to monotypes
haskell, polymorphism, types
Solution
http://hackage.haskell.org/trac/ghc/ticket/5596 is relevant here - I don't think there's any official documentation.
Problem
I previously asked this question, and after much investigation I concluded that there are special rules GHC applies only for infix `$` and `.`. For this question, I'm assuming that GHC follows the system mentioned on the RankNTypes - Haskell Prime page further elaborated in the arbitary-rank. RankNTypes - Haskell Prime page states the following: parameter variables without explicit signatures are assigned monotypes in upwards inference, but may inherit arbitrary-rank types in downwards checking. I'm presuming "assigned monotypes" means that rank-N types are converted to rank-1 types by moving all their qualifiers to the outermost level. I also believe this is what caused the unusual type error that led to me asking my previous question. So I have a few questions: 1) Is there anyway to get GHC to warn (or error) on implicit conversion to monotypes? The type error in my previous question took a while to work out, a warning of a conversion to monotype would have been more helpful than a type error. 2) Are there cases where implicit "assigning to monotypes" is sensible behaviour, and if so, could you give an example? 3) Regarding infix `$` and `.`, these seem to have special rules in GHC. Where is this documented? And are there any other special rules that GHC has, and where are they documented?