#3485: "Illegal type synonym family application in instance" error is unnecessary, should be removed

Manuel M T Chakravarty chak at cse.unsw.edu.au
Sun Sep 13 10:40:07 EDT 2009


Ashley Yakeley:
> GHC wrote:
>> #3485: "Illegal type synonym family application in instance" error  
>> is unnecessary,
>> should be removed
>> ------------------------------------- 
>> +--------------------------------------
>> Reporter:  Ashley Yakeley           |           
>> Owner:                       Type:  bug                       
>> |         Status:  closed           Priority:   
>> normal                   |      Milestone:                   
>> Component:  Compiler (Type checker)  |        Version:   
>> 6.10.4           Severity:  normal                   |      
>> Resolution:  invalid          Keywords:                            
>> |       Testcase:                         Os:  Unknown/ 
>> Multiple         |   Architecture:  Unknown/Multiple
>> ------------------------------------- 
>> +--------------------------------------
>> Changes (by chak):
>>  * status:  new => closed
>>  * resolution:  => invalid
>> Comment:
>> I am not sure what you are suggesting.  We cannot automatically  
>> transform
>> {{{
>> instance C (Fam Int)
>> }}}
>> into
>> {{{
>> instance (Fam Int ~ famint) => C famint
>> }}}
>> This works if there is only one instance, but as soon as there are  
>> two
>> such instances, they always overlap.
>> Maybe you are suggesting that we should do it anyway and programmers
>> should just take the implicit transformation into account.  I don't  
>> think
>> that this is a good idea.  It's confusing for very little benefit  
>> (as you
>> can always write the transformed instance yourself with little  
>> effort).
>
> I don't see what the problem is. "instance C (Fam Int)" has an  
> unambiguous, and logically acceptable, meaning to the compiler. Why  
> do we force the programmer to make an ugly workaround involving  
> introducing a type variable?

I think the proposed change is confusing.  Two instances

   instance C (Fam Int)
   instance C (Fam Bool)

appear to be syntactically distinct, but they semantically overlap.   
The explicit form

   instance (Fam Int ~ famint) => C famint

is IMHO much clearer and really not much more verbose.

Manuel



More information about the Glasgow-haskell-bugs mailing list