
28 Aug
2005
28 Aug
'05
11:25 p.m.
David Menendez wrote:
Juan Carlos Arevalo Baeza writes:
The way Haskell type classes work, the overlap is determined without looking at the context, so "Show a" will overlap with every possible instance for Show, including Show Int, which is predefined.
Ah. :-P Bummer.
I'm not sure what the official justification for that is, but reason is to avoid situations like this:
class A t where a :: t class B t where b :: t class C t where c :: t
instance A t => C t where c = a instance B t => C t where c = b
instance A Char where a = 'a' instance B Char where b = 'b'
What should c :: Char evaluate to?
Right. Ambiguity. But as long as there's no ambiguity, there's no reason to be this restrictive. Oh, well. JCAB