
Hi, Do I need to define indices and elem for Graph a w here explicitly ? import Data.Array data Graph a w = Array a [(a,w)] -- array (1,3) [(1,[(2,3),(3,2)])] --Given a vertex list out adjacents getAdjVertices :: (Ix a, Eq a) => a -> (Graph a w) -> [a] getAdjVertices x arr | not (x `elem` (indices arr)) = error "No such Vertex" | otherwise = extractV (arr ! 2) where extractV [] = [] extractV (x:xs) = (fst x):extractV (xs) GHCI gives : Prelude> :l programs\graph.hs [1 of 1] Compiling Main ( programs\graph.hs, interpreted ) programs\graph.hs:16:47: Couldn't match expected type `Array a e0' with actual type `Graph a w' In the first argument of `indices', namely `arr' In the second argument of `elem', namely `(indices arr)' In the first argument of `not', namely `(x `elem` (indices arr))' programs\graph.hs:17:46: Couldn't match expected type `Array Integer [(a, b0)]' with actual type `Graph a w' In the first argument of `(!)', namely `arr' In the first argument of `extractV', namely `(arr ! 2)' In the expression: extractV (arr ! 2) Failed, modules loaded: none. Prelude> Regards. Nishant