|Version 3 (modified by 11 years ago) (diff),|
overlapping instances allow instances that can unify for the same class and will choose the most specific one available
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
class overlapping Foo a where ...
- Section on overlapping instances in the GHC User's Guide.
- useful on occasion.
- including a new module can silently change behavior of a program.
- makes it very easy for incorrect programs to still typecheck
- can cause confusing error messages
- can sometimes be simulated with the extra-method trick used in the Show class of the prelude for showing lists of characters differently than lists of other things.