[Hs-Generics] Re: Owning SYB
claus.reinke at talk21.com
Fri Aug 1 10:02:02 EDT 2008
and thanks for volunteering! I include a summary of where I'm at, for
your information (and that of other interested readers;-)
> Recently, (at least) Claus and Oleg have been posting interesting
> suggestions of improvements/modifications to SYB. Those should be further
> analyzed and discussed, and finally introduced (or not) in the library. The
> generic map for SYB, for instance, evolved from the "impossible to
> implement", through the "unsafe implementation", until the latest gmap2 as
> described by Oleg . If further tests show this function behaves as
> expected, then it's clearly a good candidate for extending SYB. We should
> also rethink if other things previously deemed impossible remain so.
Further discussion welcome, of course!-) And it isn't just about getting
fmap/traverse/.. from Data/Typeable, but also about reorganizing imports
of Data instances, and providing alternatives of everywhere/everything
that avoid traversals of irrelevant subterms.
A current snapshot of my code can be found here:
It currently contains:
a) a suggested split for the Instances module, with alternatives to
Data.Generics that either export only Standard instances, or no
instances at all.
On top of the existing Syb in base, these are somewhat tricky to use,
because of the implicit re-exports of Data.Generics.Instances from
and the long-standing GHC "session accumulates instances" bug
I think this change should go into base (perhaps renaming
Data.Generics.Alt to Data.Generics.Standard, and deprecating
Data.Generics and Data.Generics.Instances), for all the reasons
discussed here recently, and because that GHC bug makes it near
impossible to provide this change as an addon to base. Existing
importers of Data.Generics or Data.Generics.Instances in core
and extralibs should be redirected to one of the new modules.
b) variants of everywhere/everything/mkQ/.. that retain the type domain
of generically extended queries, build substructure type maps of types
to be traversed, and use a slight generalisation of the Uniplate PlateData
trick to avoid traversals of irrelevant substructures (usually but not always
including, and not limited to, Strings)
This could be provided as an addon package. Performance
of generic queries and transformation on the usual Paradise
benchmark improve as expected; there is some overhead,
which is visible in an alternative benchmark where there are no irrelevant substructures.
The current code also tries to replace the linear search for
applicable specific-type-queries with Map lookup, but here
the overhead seems to outweigh the benefits, so I'll probably
disable this code in future.
One issue that I still need to address are nested types: just
as Data.Generics.PlateData, Data.Generics.GPS currently
fails for these (no finite representation of substructure types);
current plan is to recognize nested types and to fall back to
c) generic default instance methods for Control.Monad.Functor
under discusssion. could become part of that add-on package,
or move into base.
d) some Data/Typeable instances and utilities for GHC Api
needs more testing, will probably be rendered obsolete when
GHC Api starts providing those instances itself.
> Maintaining SYB, alongside with the other generic libraries, will require
> things such as:
> * Releasing packages in Hackage, properly documented with Haddock;
> * Updating such packages as necessary for new releases of GHC;
> * Writing examples of how to use the libraries (from a user perspective);
> * Writing testsuites, which are important for checking backwards
> compatibility of any changes;
> * Having an updated webpage linking to the library sources, documentation,
> possibly a bug tracker, etc.
> These are all things we plan to do for the libraries.
> Additionally, we could think of improving syb-with-class  in parallel
> with regular SYB. This is something to ask to its maintainer.
>  http://www.cs.uu.nl/research/techreps/UU-CS-2008-019.html
>  http://www.haskell.org/pipermail/generics/2008-July/000362.html
> Generics mailing list
> Generics at haskell.org
More information about the Libraries