Yes, thank you. Here's my simple fix: newtype Point = Point Int instance Show Point where show (Point a) = [chr $ a + 48] data Vector = Vector [Point] instance Show Vector where show (Vector ys) = let show' [z] = show z show' (x:xs) = show x ++ ", " ++ show' xs show' [] = [] in "(" ++ show' ys ++ ")" And I added this function: createPoint :: Int -> PointcreatePoint x = Point x When I loaded the file containing all this into ghci and executed 'Vector $ map createPoint [1..5]' the result was '(1, 2, 3, 4, 5)' (without the quotes).This was actually more or less a test question as I'm new to haskell-cafe, but I hope people who will read this message will learn from my mistake. Thank you. > From: aslat...@gmail.com > Date: Mon, 28 Nov 2011 16:20:54 -0600 > Subject: Re: [Haskell-cafe] (no subject) > To: dub...@hotmail.com > CC: haskell-cafe@haskell.org > > On Mon, Nov 28, 2011 at 4:12 PM, Willem Obbens <dub...@hotmail.com> wrote: > > Hello, > > I get this error when I try to derive an instance of the Show typeclass: > > Abc.hs:21:60: > > Couldn't match expected type `Vector' with actual type `[Point]' > > In the first argument of `show'', namely `xs' > > In the second argument of `(++)', namely `show' xs' > > In the second argument of `(++)', namely `", " ++ show' xs' > > Failed, modules loaded: none. > > Here's the faulty code: > > newtype Point = Point Int > > instance Show Point where > > show (Point a) = [chr $ a + 48] > > > > data Vector = Vector [Point] > > instance Show Vector where > > show (Vector ys) = > > let show' (Vector [z]) = show z > > show' (Vector (x:xs)) = show x ++ ", " ++ show' xs > > show' (Vector []) = [] > > in "(" ++ show' ys ++ ")" > > Here you're treating the value 'ys' as if its type was 'Vector', but > its type is '[Point]'. > > Does that help? > > Antoine
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe