<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>


<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>

<div dir="ltr">Yes, thank you. Here's my simple fix:<div><br></div><div>newtype Point = Point Int<br>instance Show Point where</div><div>&nbsp; &nbsp;show (Point a) = [chr $ a + 48]</div><div><br>data Vector = Vector [Point]<br>instance Show Vector where<br>&nbsp; &nbsp;show (Vector ys) =<br>&nbsp; &nbsp; &nbsp; let show' [z] &nbsp; &nbsp; = show z<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;show' (x:xs) &nbsp;= show x ++ ", " ++ show' xs<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;show' [] &nbsp; &nbsp; &nbsp;= []<br>&nbsp; &nbsp; &nbsp; in &nbsp;"(" ++ show' ys ++ ")"</div><div><br></div><div>And I added this function:&nbsp;</div><div><br></div><div><div>createPoint :: Int -&gt; Point</div><div>createPoint x = Point x</div><div><br></div><div>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).</div><div>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.</div><div><br></div><div>Thank you.</div><br><div>&gt; From: aslatter@gmail.com<br>&gt; Date: Mon, 28 Nov 2011 16:20:54 -0600<br>&gt; Subject: Re: [Haskell-cafe] (no subject)<br>&gt; To: dubl-u@hotmail.com<br>&gt; CC: haskell-cafe@haskell.org<br>&gt; <br>&gt; On Mon, Nov 28, 2011 at 4:12 PM, Willem Obbens &lt;dubl-u@hotmail.com&gt; wrote:<br>&gt; &gt; Hello,<br>&gt; &gt; I get this error when I try to derive an instance of the Show typeclass:<br>&gt; &gt; Abc.hs:21:60:<br>&gt; &gt; &nbsp; &nbsp; Couldn't match expected type `Vector' with actual type `[Point]'<br>&gt; &gt; &nbsp; &nbsp; In the first argument of `show'', namely `xs'<br>&gt; &gt; &nbsp; &nbsp; In the second argument of `(++)', namely `show' xs'<br>&gt; &gt; &nbsp; &nbsp; In the second argument of `(++)', namely `", " ++ show' xs'<br>&gt; &gt; Failed, modules loaded: none.<br>&gt; &gt; Here's the faulty code:<br>&gt; &gt; newtype Point = Point Int<br>&gt; &gt; instance Show Point where<br>&gt; &gt; &nbsp; &nbsp;show (Point a) = [chr $ a + 48]<br>&gt; &gt;<br>&gt; &gt; data Vector = Vector [Point]<br>&gt; &gt; instance Show Vector where<br>&gt; &gt; &nbsp; &nbsp;show (Vector ys) =<br>&gt; &gt; &nbsp; &nbsp; &nbsp; let show' (Vector [z]) &nbsp; &nbsp; = show z<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show' (Vector (x:xs)) &nbsp;= show x ++ ", " ++ show' xs<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show' (Vector []) &nbsp; &nbsp; &nbsp;= []<br>&gt; &gt; &nbsp; &nbsp; &nbsp; in &nbsp;"(" ++ show' ys ++ ")"<br>&gt; <br>&gt; Here you're treating the value 'ys' as if its type was 'Vector', but<br>&gt; its type is '[Point]'.<br>&gt; <br>&gt; Does that help?<br>&gt; <br>&gt; Antoine<br></div></div></div>
                                               </div></body>
</html>