The following code snippet not works correctly.

 

>data Obj = Obj {_id, p1, p2::Int} deriving (Show, Read)

 

>showObj :: Obj -> String

>showObj o = show o

 

>main = do print (showObj (read "Obj {_id=1,p1=10,p2=20}"))

>              return ()

 

The reason is because I used the property name with underscore char like “_id”.

Looking into auto generated class codes and seeing they show it should encompass identifiers with special characters with parenthesis, so I tried "Obj {(_id)=1,p1=10,p2=20}" as argument of read func. But, the result is same, parse error.

 

Is this problem by-design or bug? Or Am I missing any point?

 

Thanks,

/JongKeun

 

 

-----Original Message-----
From: Simon Peyton-Jones
Sent: Friday, February 07, 2003 5:41 PM
To: Jong Keun Na; haskell-cafe@haskell.org
Subject: RE: Auto generated instance codes through 'deriving'

 

Try -ddump-deriv

            http://haskell.cs.yale.edu/ghc/docs/latest/html/users_guide/options-debugging.html#DUMPING-OUTPUT

 

Simon

 

-----Original Message-----
From: Jong Keun Na [mailto:jongkn@microsoft.com]
Sent: 07 February 2003 06:15
To: haskell-cafe@haskell.org
Subject: Auto generated instance codes through 'deriving'

 

Hello folks,

Is there any method with which I can see instance’s codes generated automatically by using deriving’ keyword in GHC?

I’m curious in how GHC generates Read’ class’s instance code for user-defined data type.

Any help will be great appreciated.

/JongKeun