Automatically derived instances
Juan Carlos Arevalo Baeza
jcab.lists at JCABs-Rumblings.com
Sun Aug 28 23:25:45 EDT 2005
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.
More information about the Glasgow-haskell-users