[Haskell-cafe] (no subject)

Willem Obbens dubl-u at hotmail.com
Mon Nov 28 23:12:28 CET 2011

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 Intinstance 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 ++ ")"
What I'm trying to do, is to print out a vector like "Vector [Point 1, Point 2, Point 3]" as "(1, 2, 3)".My question is: what should I change in order to make it work?
Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111128/22a8821b/attachment.htm>

More information about the Haskell-Cafe mailing list