Ah yes, this is a genuine bug. Haskell 98 changed at some point to allow identifiers and field labels with a leading ‘_’, but the library didn’t keep pace.
I’ll fix GHC.
HOWEVER, the sad thing is that the same bug is in the Haskell 98 Report itself, now begin printed. The definition of lex is wrong.
Ah well, I knew this would happen. I’d better start keeping a new bug list!
Simon
-----Original Message-----
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-----
Try -ddump-deriv http://haskell.cs.yale.edu/ghc/docs/latest/html/users_guide/options-debugging.html#DUMPING-OUTPUT
Simon
-----Original
Message-----
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 |
Title: Auto generated instance codes through 'deriving'
- Re: Error in Haskell 98 Report 'lex' function Simon Peyton-Jones
- Re: Error in Haskell 98 Report 'lex' function Malcolm Wallace
- Feature Request for Haskell 98 list syntax? w... Shae Matijs Erisson