
On Sat, Jul 9, 2011 at 5:59 PM, yi huang
On Sat, Jul 9, 2011 at 6:45 PM, Tom Murphy
wrote: On 7/9/11, yi huang
wrote: I'm trying to create a haskell implementation of json rpc, I try to define protocol using record like this:
data Request = Request { version :: Integer , id :: Integer , method :: String , args :: [Value] } deriving (Typeable, Data, Show)
so i can use json library to encode/decode it. But this code fails, because haskell will define access function automaticlly, and function names conflicts. My question is, is there a way i can define record without access function, so i can have same attribute name in multiple record.
If you really want to keep those attribute names exactly, you'll have to check where the conflict is and find a way not to import the conflicting function name. Here I guess "id" is the big problem since it comes with the prelude you'll have to use the NoImplicitPrelude extension and explicitly "import Prelude hiding (id)", I suggest you make a separate module for your type definition so you don't have to worry about that in the rest of your code. -- Jedaï