[commit: ghc] master: Improve `Foldable` instance for `Array` (212a350)

git at git.haskell.org git at git.haskell.org
Thu Nov 13 08:17:58 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/212a350547e950cc5be465a3d76e346ef14bf2ab/ghc

>---------------------------------------------------------------

commit 212a350547e950cc5be465a3d76e346ef14bf2ab
Author: David Feuer <David.Feuer at gmail.com>
Date:   Thu Nov 13 09:10:57 2014 +0100

    Improve `Foldable` instance for `Array`
    
    Previously, `Array`s were simply converted to lists, and the list
    methods used. That works acceptably well for `foldr` and `foldr1`, but
    not so sensibly for most other things. Left folds ended up "twisted" the
    way they are for lists, leading to surprising performance
    characteristics.
    
    Moreover, this implements `length` and `null` so they check the array
    size directly.
    
    Finally, a test is added to the testsuite ensuring the overridden
    `Foldable` methods agree with their expected default semantics.
    
    Addresses #9763
    
    Reviewed By: hvr, austin
    
    Differential Revision: https://phabricator.haskell.org/D459


>---------------------------------------------------------------

212a350547e950cc5be465a3d76e346ef14bf2ab
 libraries/base/Data/Foldable.hs           |  18 +++--
 libraries/base/GHC/Arr.hs                 |  59 +++++++++++++-
 libraries/base/tests/all.T                |   1 +
 libraries/base/tests/foldableArray.hs     | 129 ++++++++++++++++++++++++++++++
 libraries/base/tests/foldableArray.stdout |  13 +++
 5 files changed, 214 insertions(+), 6 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 212a350547e950cc5be465a3d76e346ef14bf2ab


More information about the ghc-commits mailing list