On Fri, Dec 5, 2008 at 1:29 AM, Martijn van Steenbergen <span dir="ltr">&lt;<a href="mailto:martijn@van.steenbergen.nl">martijn@van.steenbergen.nl</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dmitri O.Kondratiev wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
-- &nbsp;How to define Show [MyType] ?<br>
</blockquote>
<br>
Define instance Show MyType and implement not only show (for 1 value of MyType) but also showList, which Show provides as well. You can do all the magic in there.<br>
<br>
HTH,<br><font color="#888888">
<br>
Martijn.<br>
<br>
</font></blockquote></div><br>Thanks everybody for your help! <br>I tried to implement showList, but get the same error:<br><br>{-- <br>-- from Prelude:<br><span class="keyword">type</span> <a name="t:ShowS"></a><b>ShowS</b> = <a href="file:///C:/usr/ghc-6.6.1/doc/html/libraries/base/Prelude.html#t%3AString">String</a> -&gt; <a href="file:///C:/usr/ghc-6.6.1/doc/html/libraries/base/Prelude.html#t%3AString">String</a> <br>
<b>showList</b> :: [a] -&gt; <a href="file:///C:/usr/ghc-6.6.1/doc/html/libraries/base/Prelude.html#t%3AShowS">ShowS</a><br>--}<br><br>myShows::ShowS<br>myShows s = s ++ &quot;\n&quot;<br><br>data ShipInfo = Ship {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name :: String,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kind :: String,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; canons :: Int<br>} deriving Show<br><br>-- I get this error again:<br>instance (Show [ShipInfo]) where<br>&nbsp;&nbsp;&nbsp; showList [] = myShows []<br>&nbsp;&nbsp;&nbsp; showList (x:xs)&nbsp; = myShows &quot;x&quot; ++ showList xs<br>
<br>&nbsp;&nbsp;&nbsp; Illegal instance declaration for `Show [ShipInfo]&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (The instance type must be of form (T a b c)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where T is not a synonym, and a,b,c are distinct type variables)<br>&nbsp;&nbsp;&nbsp; In the instance declaration for `Show [ShipInfo]&#39;<br>
Failed, modules loaded: none.<br><br>-- What am I doing wrong?<br>Thanks!<br>