Class instance specificity order (was Re: Fundeps and type equality)
twhitehead at gmail.com
Thu Jan 10 23:12:10 CET 2013
On January 10, 2013 13:56:02 Richard Eisenberg wrote:
> Class instances that overlap are chosen among by order of specificity;
Sorry to jump in the middle here, but this caught my attention as this sort of
specificity determination is exactly what I had in mind when I was working on
my "The shape of things: a reason for type preference" paper.
I would love to know what approach GHC is currently taking to determine this.
The document gives the example of matching C Int [Int] against
C Int a
C a Bool
C Int [a]
C Int [Int]
This is easy though. Obviously the last match is best because it is exact.
What if we have something like C Int [[Int]] against
C Int b
C a [[b]]
though. How is the best match determined in this case?
More information about the Glasgow-haskell-users