I'm wondering if this would be a reasonable feature request (even better if it already exists and I don't know how to access it).
An example of why this is desirable is the pipes library. Pipes defines a type:
data Proxy a' a b' b m r
with a ton of aliases, a few of which are:
type Effect = Proxy X () () X
type Producer b = Proxy X () () b
type Pipe a b = Proxy () a () b
type Consumer a = Proxy () a () X
As you can imagine, this is a worst-case scenario for clear error messages. As a programmer reading the documentation, you're thinking in terms of simpler types with few parameters but all of the error messages are in terms of a monster type with six parameters like so:
Couldn't match expected type ‘Proxy () Bool () b0 IO ()’
with actual type ‘Int -> Pipe Bool Integer m0 r0’
Would be clearer if that message could be like:
Couldn't match expected type ‘Pipe Bool Integer IO ()’
with actual type ‘Int -> Pipe Bool Integer IO ()’
As a side question, why does GHC lose track of the specific type Integer that it replaces with b0 while somehow it remembers Bool? The declared type is:
(Monad m)
=> Int
-> Pipe Bool Integer m r
Anyway ...
Would better error reporting for type aliases be possible as a feature request or does GHC forget the alias long before detecting the type error? (Seems to me like GHC must keep track of the alias because GHC seems to remember it in the "actual type" part of the error message, but I have no clue how a compiler works.)