
On 20 October 2011 19:12, Rustom Mody
And of course which are easier and which more difficult to dig into.
If you're looking for an example for the new GHC generic mechanism: I recently added a generic default implementation to the ToJSON and FromJSON type classes of the aeson package (not in mainline yet): class ToJSON a where toJSON :: a -> Value default toJSON :: (Generic a, GToJSON (Rep a)) => a -> Value toJSON = gToJSON . from class FromJSON a where parseJSON :: Value -> Parser a default parseJSON :: (Generic a, GFromJSON (Rep a)) => Value -> Parser a parseJSON = fmap to . gParseJSON See: https://github.com/basvandijk/aeson/blob/newGenerics/Data/Aeson/Types/Intern... It wasn't that difficult to implement. However I did need to use some advanced type-level tricks to convert to and from records. Regards, Bas