Re: [Haskell-cafe] Adding a field to a data record

2009-07-29 Thread José Pedro Magalhães
Hello Henry, The paper A Lightweight Approach To Datatype-Generic Rewriting [1] describes a way to generically add a constructor to any regular datatype using type-indexed datatypes [2]. A similar technique could be used to add a new field to each constructor. Then you get something like: data

[Haskell-cafe] Adding a field to a data record

2009-07-28 Thread Henry Laxen
Dear Group, It seems to me this should be easy, but I can't quite figure out how to do it without a lot of typing. Here is the question: Suppose you have a data type like: Data Foo = Foo { a :: Int, b :: Int, ... many other fields ... y :: Int } deriving (Eq, Read, Show, Typeable, Data)

Re: [Haskell-cafe] Adding a field to a data record

2009-07-28 Thread Malcolm Wallace
and perhaps use emacs to query-replace all the Foo1's back to Foo's At least this bit can be avoided easily enough, by using module qualification during the conversion process. module Original (Foo(..)) where data Foo = Foo { ... y :: Int } deriving ... module New (Foo(..)) where