Skip to content
  • David Feuer's avatar
    Improve `Foldable` instance for `Array` · 212a3505
    David Feuer authored and Herbert Valerio Riedel's avatar Herbert Valerio Riedel committed
    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
    212a3505