Simon Peyton-Jones simonpj at
Wed Jan 28 12:56:01 EST 2004

Try the new stuff (in GHC6.2) in the Data.Generics library.
In particular the class Data, and its related types Constr and DataType

Ralf and I are writing a paper about the extensions you'll find there,
which aren't in our original "scrap your boilerplate" paper. 


| -----Original Message-----
| From: glasgow-haskell-users-bounces at
| bounces at] On Behalf Of MR K P SCHUPKE
| Sent: 21 January 2004 12:35
| To: glasgow-haskell-users at
| Subject: Generics...(ish)
| I am currently using template haskell to generate code to work on a
| record data type... This however is not very pretty, and I wondered if
| there was another way to do what I want in GHC. I need to iterate over
| the contents of a record for example:
| data Test = Test { a :: Int, b :: String, c :: Float }
| If I derive Typeable, I can compare the data-type, but not decompose
| I don't know much about generics, and was wondering if I might be able
| do it that way...
| The functionality I need is equivalent to being able to compare to
| for example, consider the type above, and the type below:
| data Test2 = Test2 { x :: Int, y :: String, z :: Float, zz :: String }
| i need to construct a function that could output the differenc between
| types, position at a time, so for the above the output would be:
| Test2 contains extra String field.
| or if "y" was to have the type Float,
| Position 2 : Types differ (Test has String, Test2 has Float)
| Test2 contains extra String field.
| I could do this easily if Typeable was a concrete type just by using
| case statements...
| 	Regards,
| 	Keean Schupke.
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list