[Haskell-beginners] Show for Parameterized Type

Hartmut hartmut0407 at googlemail.com
Sun Aug 7 23:39:02 CEST 2011


Hello,

I made a parameterized data type EW, which builds on a type of class Read
and Show.
When showing EW's it shall prefix the output with "EW:".


data (Read a,Show a) => EW a = EW a

x01 = EW 20
x02 = EW "Test"

instance Show (EW a) where
  show (EW x) = show "EW:" ++ show x


But I got a syntax error with this above at "show (EW x) = ...":
No instance of (Read a) asrising a use of 'EW' in the pattern ....

How can I formulate this show method correctly?

I'd appreciate Your help
Hartmut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110807/94906f41/attachment.htm>


More information about the Beginners mailing list