| 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 | |
| | 18 | Hugs 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 | {{{ |
| | 21 | instance C Int b |
| | 22 | instance 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 | |
| | 28 | An 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 |