Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Ross Paterson <ross <at> soi.city.ac.uk>
Subject: proposal #2461: add Traversable generalizations of mapAccumL and mapAccumR
Newsgroups: gmane.comp.lang.haskell.libraries
Date: Tuesday 22nd July 2008 16:12:48 UTC (over 9 years ago)
The proposal is to add the following functions to Data.Traversable,
generalizing the list versions in Data.List:

    -- |The 'mapAccumL' function behaves like a combination of 'fmap'
    -- and 'foldl'; it applies a function to each element of a structure,
    -- passing an accumulating parameter from left to right, and returning
    -- a final value of this accumulator together with the new structure.
    mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t
c)

    -- |The 'mapAccumR' function behaves like a combination of 'fmap'
    -- and 'foldr'; it applies a function to each element of a structure,
    -- passing an accumulating parameter from right to left, and returning
    -- a final value of this accumulator together with the new structure.
    mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t
c)

These functions are handy for things like labelling trees, zipping, etc.

Deadline: 3 weeks
 
CD: 3ms