[Haskell] type inference & instance extensions

Corey O'Connor coreyoconnor at gmail.com
Tue Jan 27 13:05:39 EST 2009

On Tue, Jan 27, 2009 at 4:51 AM,  <oleg at okmij.org> wrote:
> Doug McIlroy wrote:
>> A fragment of an attempt to make pairs serve as complex numbers,
>> using ghc/hugs extensions:
>>         instance Num a => Num (a,a) where
>>                 (x,y) * (u,v) = (x*u-y*v, x*v+y*u)
> The recent versions of GHC have a nifty equality constraint, so the
> code can be written simply

I'm confused on why
instance Num a => Num (a, a) where

is not equivalent to
instance (Num a, Num b, a ~ b) => Num (a, b) where

I don't know the details of the type inference algorithm. What am I
missing to understand why they are not the same?

Corey O'Connor

More information about the Haskell mailing list