Continuing in my quest to understand type design in Haskell, here's another 
episode that leaves me scratching my head:

module Foo where

class Vect v a where
  (<+>) :: Floating a => v a -> v a -> v a

data Vector a = Vector a a a

instance Vect Vector a where
  (<+>) (Vector x1 y1 z1) (Vector x2 y2 z2)
         = Vector (x1+x2) (y1+y2) (z1+z2)

instance Vect [Vector a] a where
  (<+>) l1 l2 = zipWith (<+>) l1 l2


The problem is the last instance declaration. Hugs says "Illegal type in class 
constraint", which is not very explicit (which class constraint?). GHCI is a 
bit more verbose:

    Kind error: Expecting kind `* -> *', but `[Vector a]' has kind `*'
    When checking kinds in `Vect [Vector a] a'
    In the instance declaration for `Vect [Vector a] a'

I have vague memories of seeing mentioned the concept of "kind", but I can't 
remember where. Any help would be appreciated!

Konrad.

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to