Re: [Hs-Generics] Re: Add everywhereM' to Data.Generics.Schemes

Hi Matthias, I started writing an email, but decided a blog post would be a better place to put down my thoughts on everywhere': http://neilmitchell.blogspot.com/2010/04/dangerous-primes-why-uniplate-doesn...
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.
I 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 framework. Thanks, Neil
Am 18.04.2010 09:38 schrieb Neil Mitchell:
Hi,
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 everywhere.
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
participants (1)
-
Neil Mitchell