Syb Renovations? Issues with Data.Generics

Claus Reinke claus.reinke at
Thu Jul 31 11:43:01 EDT 2008

> maybe in those cases of "convenience" we could use a tool like
> Data.Derive, and make some name to derive with it like "DubiousData".
> Then the dubious Data instances wouldn't have to be defined/imported.
> I wonder if it would be possible to have Derive have a "NotSoDubiousData"
> that somehow figured out whether dubious types were involved and
> rejected them.. 

generating instances of a different class might lead to ambiguities/
overlaps in use, but I like the idea of making deriving smarter to
get rid of dummy instances. Let me see if I got your idea correctly.

    data Something a = Something a (IO a)

Currently, we have two choices to get 'Data Something':

- use naive deriving, for which we'd need to supply both
    'Data a' and 'Data (IO a)', with unwanted consequences
    for the latter

- write the Data instance for Something by hand, skipping
    the 'IO a' component

If deriving was only a little bit smarter, we could write:

    data Something a = Something a {-# Data: skip #-} (IO a)
        deriving (Data,Typeable)

and the deriving mechanism could give us a modified Data
instance for Something that doesn't need 'Data (IO a)'. No
need for instances we can't really write, and a clear hint in
the source code that the 'IO a' component is treated specially
(skipped rather than traversed)!

I like the idea,

More information about the Libraries mailing list