New Data.Foldable methods
See http://thread.gmane.org/gmane.comp.lang.haskell.libraries/22828
The current version of the proposal at time of writing:
Add the following to
Foldable
:
length
— often stored as a separate field for //O(1)// access
null
— called very often and slightly faster thanfoldr (\_ _ -> False) True
for some containers
toList
— may be the identity or nearly so, and this fact may not be statically available to the foldr/id rule
sum
,product
— may be cached internally in tree nodes for fast update, giving //O(1)// access; may be calculated in parallel.
maximum
,minimum
— //O(n)// for a search tree; //O(1)// for a finger tree.
elem
— //O(log n)// for search trees; likely better for hash tables and such.*Don't** add anything to
Traversable
, becausescanl1
andscanr1
are not worth the extra dictionary weight.