|
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'
- Auto generated instance codes through 'deriving' Jong Keun Na
- RE: Auto generated instance codes through 'derivin... Simon Peyton-Jones
- Jong Keun Na
