On Fri, Dec 5, 2008 at 1:29 AM, Martijn van Steenbergen <martijn@van.steenbergen.nl> wrote:
Dmitri O.Kondratiev wrote:
--  How to define Show [MyType] ?
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.
HTH,
Martijn.
Thanks everybody for your help! 
I tried to implement showList, but get the same error:
{-- 
-- from Prelude:
type ShowS = String -> String 
showList :: [a] -> ShowS
--}
myShows::ShowS
myShows s = s ++ "\n"
data ShipInfo = Ship {
      name :: String,
      kind :: String,
      canons :: Int
} deriving Show
-- I get this error again:
instance (Show [ShipInfo]) where
    showList [] = myShows []
    showList (x:xs)  = myShows "x" ++ showList xs
    Illegal instance declaration for `Show [ShipInfo]'
        (The instance type must be of form (T a b c)
         where T is not a synonym, and a,b,c are distinct type variables)
    In the instance declaration for `Show [ShipInfo]'
Failed, modules loaded: none.
-- What am I doing wrong?
Thanks!