[commit: ghc] master: Make law for Foldable.length explicit (cd5a970)

git at git.haskell.org git at git.haskell.org
Tue Aug 22 15:22:12 UTC 2017


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

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

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

commit cd5a9709a6e6647e0e7dc78f863820ca53bc99b0
Author: Alain O'Dea <alain.odea at gmail.com>
Date:   Tue Aug 22 08:47:07 2017 -0400

    Make law for Foldable.length explicit
    
    Test Plan: Documentation only. Not necessary.
    
    Reviewers: austin, hvr, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3878


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

cd5a9709a6e6647e0e7dc78f863820ca53bc99b0
 libraries/base/Data/Foldable.hs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libraries/base/Data/Foldable.hs b/libraries/base/Data/Foldable.hs
index e33d45e..08ba9d4 100644
--- a/libraries/base/Data/Foldable.hs
+++ b/libraries/base/Data/Foldable.hs
@@ -99,6 +99,8 @@ infix  4 `elem`, `notElem`
 --
 -- > fold = foldMap id
 --
+-- > length = getSum . foldMap (Sum . const  1)
+--
 -- @sum@, @product@, @maximum@, and @minimum@ should all be essentially
 -- equivalent to @foldMap@ forms, such as
 --



More information about the ghc-commits mailing list