[Hs-Generics] Re: Add everywhereM' to Data.Generics.Schemes
ndmitchell at gmail.com
Sun Apr 25 10:29:21 EDT 2010
I started writing an email, but decided a blog post would be a better
place to put down my thoughts on everywhere':
> This said, if I understand your last post correctly, the use of everywhereM'
> would be a bug here in your eyes. Do you agree? Because I don't think so.
It's possible to use everywhere' correctly, but not trivial. Using
descend it's trivial to get right, which is much safer. Read the blog
post for my best thoughts why.
> haven't done a lot of testing yet, but each case where a replacement has to
> be performed works as expected. And even if it's not a bug, do you suggest
> to drop everywhereM' and use uniplate instead, just to play it safe?
I recommend to everyone they drop whatever generics solution they are
using and switch to Uniplate :-) [If Uniplate can express what you
want - it's one of the least powerful generics libraries - but gets
almost all the common uses]
I think using descend (from Uniplate) or compos (from Compos paper),
or writing a descend/compos operator for SYB, is the right way to go.
It's a nicer primitive, and it's perfectly definable in most generics
frameworks. I think everywhere' is a bad primitive in any generics
> Am 18.04.2010 09:38 schrieb Neil Mitchell:
>> I thought a lot about everywhere' when writing uniplate. I have an
>> equivalent of everywhere (transform), but no transform'. In the end I
>> decided that it was virtually impossible to use everywhere' correctly,
>> and that almost every call of everywhere' was either somewhere an
>> everywhere would have worked equally well, or a bug. I then went
>> through all the Haskell source code I could find, found about 6 calls
>> to everywhere', and all of them would have performed the same job as
>> So, my suggestion is that everywhereM' probably isn't very useful, but
>> descend/descendM (or compos) is a useful top-down traversal scheme.
>> Thanks, Neil
More information about the Libraries