[Haskell-beginners] Issue with MultiParamTypeClasses

Ovidiu Deac ovidiudeac at gmail.com
Sat Dec 5 17:35:42 UTC 2015


I have the following code:

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

class Graph g a where
    vertices :: g a -> [a]
    edges :: g a-> [(a, a)]

type AdjList a = [(a,[a])]

instance Graph AdjList Int where
    vertices g = map fst g
    edges g = concatMap listEdges g
        where listEdges (startV, edges) = map (\endV -> (startV, endV)) edges

but the compiler complains:

"""Type synonym ���AdjList��� should have 1 argument, but has been given none
    In the instance declaration for ���Graph AdjList Int��� """

How can I fix this error?

Thanks!


More information about the Beginners mailing list