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

Neil Mitchell ndmitchell at gmail.com
Sun Apr 18 03:38:10 EDT 2010


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

On Mon, Apr 12, 2010 at 8:35 PM, José Pedro Magalhães <jpm at cs.uu.nl> wrote:
> Hi Maciej,
> Data.Generics.Schemes is now on the syb package, and I'm its maintainer. But I'm not so sure it is wise to start adding more traversal schemes of this form, since there might be many of them: if we include everywhereM', we certainly have to include the bottom-up everywhereM too. Then there are the possible Applicative variants, etc...
> In general, since these traversal functions are small and everywhere and everywhere' already show the pattern of how to write them, maybe it's best that they are defined by the user, unless there is some general consensus that they would be widely useful.
> Cheers,
> Pedro
> On Mon, Apr 12, 2010 at 20:56, Maciej Podgurski <maciej.podgurski at googlemail.com> wrote:
>> Hello,
>> as an analogue to everywhere', I suggest adding everywhereM' to Data.Generics.Schemes. The implementation would be
>>   everywhereM' :: Monad m => GenericM m -> GenericM m
>>   everywhereM' f x = do { x' <- f x;
>>                           gmapM (everywhereM' f) x' }
>> Best wishes,
>> Maciej
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
> _______________________________________________
> Generics mailing list
> Generics at haskell.org
> http://www.haskell.org/mailman/listinfo/generics

More information about the Libraries mailing list