[Hs-Generics] Re: Syb Renovations? Issues with Data.Generics
Claus Reinke
claus.reinke at talk21.com
Thu Jul 31 11:25:03 EDT 2008
> That is the whole point, isn't it? The Data framework isn't designed
> to cope with things like (a->b) or (IO a), so there are no good instances
> one could define for these types (if anyone can suggest better instances,
> please do!-). Hence the incomplete instances mixed in with the standard
> ones in Data.Generics.Instances.
Actually, one could try to improve at least the gmapT and related
methods, since they are meant to map over immediate subterms:
gmapT f fun = f . fun
-- instead of gmapT f fun = fun
gmapT f io = (return . f) =<< io
-- instead of gmapT f io = io
(we simply eta-expand until we can get hold of the "subterms",
then apply f)
While this would be more suitable for some applications of Data,
such as everywhere (and everything, if we do the same for gmapQ),
it still doesn't give consistent or complete instances of Data for
functions or IO. But I thought I'd mention it an example of usefully
different instances, rather than usefully absent instances for these types.
Claus
More information about the Generics
mailing list