
1 Aug
2008
1 Aug
'08
1:16 p.m.
Ross Paterson wrote:
The proposal is to add the following functions to Data.Traversable,
mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)
mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)
It is useful as an education effort so that people can see how/which functions can be naturally generalized -- or if converting code from using Lists. (Probably it's useful in its own right, but I haven't used Traversable recently enough to be able to report on that.) I often thought that even Data.List.mapAccum[LR] is just on the edge of deserving to be its own function seperate from foldl/foldr anyway... -Isaac