Issue with MultiParamTypeClasses

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!

Hello, This is not an issue with MultiParamTypeClasses. It's just that type synonyms always have to be used fully applied. You can use a newtype instead: newtype AdjList a = AdjList [(a,[a])] instance Graph AdjList Int where (...) Best regards, Marcin Mrotek

Indeed, with newtype it works like a charm. Thanks!
On Sun, Dec 6, 2015 at 8:26 PM, Marcin Mrotek
Hello,
This is not an issue with MultiParamTypeClasses. It's just that type synonyms always have to be used fully applied. You can use a newtype instead:
newtype AdjList a = AdjList [(a,[a])]
instance Graph AdjList Int where (...)
Best regards, Marcin Mrotek
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (2)
-
Marcin Mrotek
-
Ovidiu Deac