[Haskell-beginners] Can i define a record without defining access method.

yi huang yi.codeplayer at gmail.com
Sat Jul 9 12:33:54 CEST 2011


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)

data Response = Response {
    version :: Integer
  , id      :: Integer
  , code    :: Integer
  , method   :: String
  , result  :: 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.


-- 
http://www.yi-programmer.com/blog/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110709/8651d034/attachment.htm>


More information about the Beginners mailing list