Changes between Version 3 and Version 4 of OverlappingInstances


Ignore:
Timestamp:
Dec 13, 2005 11:44:54 AM (9 years ago)
Author:
ross@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OverlappingInstances

    v3 v4  
    66== Brief Explanation == 
    77 
    8 overlapping instances allow instances that can unify for the same class and will choose the most specific one available 
     8Instances are allowed to overlap, as long as there is a most specific one in any case. 
     9Contexts of instances play no part in testing for overlapping. 
    910 
    10 An alternate to what GHC implements would be to declare whether a class may be overlapping on a class by class basis. perhaps with something like 
     11== References == 
     12 * [http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#instance-overlap Overlapping instances] in the GHC User's Guide. 
     13 * [http://cvs.haskell.org/Hugs/pages/users_guide/class-extensions.html#OVERLAPPING-INSTANCES Overlapping instances] in the Hugs User's Guide. 
     14 * IncoherentInstances 
     15 
     16== Variations == 
     17 
     18Hugs compares instance declarations, while GHC delays tests until the instances are used. 
     19 * Hugs considers instances to be overlapping if they are unifiable, e.g. 
     20   {{{ 
     21instance C Int b 
     22instance C a Bool 
     23}}} 
     24   Similarly the "most specific" test is applied to instances (though not as cleverly as it could be). 
     25 * GHC only requires `-fallow-overlapping-instances` if it needs to resolve a constraint that overlaps with both, e.g. `C Int Char` is fine, but `C a Bool` overlaps. 
     26   Similarly a most specific instance is needed only for constraints encountered in type checking. 
     27 
     28An alternative to what GHC implements would be to declare whether a class may be overlapping on a class by class basis, perhaps with something like 
    1129{{{ 
    1230class overlapping Foo a where 
     
    1432}}} 
    1533 
    16 == References == 
    17  * [http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#instance-overlap Section on overlapping instances] in the GHC User's Guide. 
    18  
    19  
    2034== Pros == 
    2135 * useful on occasion. 
    22  
    2336 
    2437== Cons ==