MR K P SCHUPKE k.schupke at
Wed Jan 21 12:34:53 EST 2004

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 it,
I don't know much about generics, and was wondering if I might be able to
do it that way...

The functionality I need is equivalent to being able to compare to instances,
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 the
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...

	Keean Schupke.

More information about the Glasgow-haskell-users mailing list