12
votes

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?

1
This could be of interest.n. 1.8e9-where's-my-share m.
As to point 3, my suspicion is that they're only documented in the GHC source. I'm not aware of any documentation at any rate. You might try asking on the ghc-users list for an authoritative answer.John L

1 Answers

3
votes

http://hackage.haskell.org/trac/ghc/ticket/5596 is relevant here - I don't think there's any official documentation.