[Haskell-beginners] Trouble using MultiParamTypeClasses

Amy de Buitléir amy at nualeargais.ie
Tue Nov 22 13:41:11 CET 2011


I would be very grateful if someone could tell me what I'm doing wrong. Here's my
code:

-----
{-# LANGUAGE MultiParamTypeClasses #-}

class Eq a => Graph g a where
  nodes :: g a -> [a]
  neighbours :: g a -> a -> [a]

data WeightedGraph a w = WeightedGraph [(a, a, w)]

instance Eq a => Graph a (WeightedGraph w a) where
  nodes = [] --stub
  neighbours = [] --stub
-----

And here's the error message:

temp.hs:9:24:                                                                  
                                                     
    Kind mis-match                                                             
                                                     
    The first argument of `Graph' should have kind `* -> *',                   
                                                     
    but `a' has kind `*'                                                       
                                                     
    In the instance declaration for `Graph a (WeightedGraph w a)'              
                                                     




More information about the Beginners mailing list