On Fri, Dec 5, 2008 at 1:29 AM, Martijn van Steenbergen < [EMAIL PROTECTED]> 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<file:///C:/usr/ghc-6.6.1/doc/html/libraries/base/Prelude.html#t%3AString>-> String<file:///C:/usr/ghc-6.6.1/doc/html/libraries/base/Prelude.html#t%3AString> *showList* :: [a] -> ShowS<file:///C:/usr/ghc-6.6.1/doc/html/libraries/base/Prelude.html#t%3AShowS> --} 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!
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe