From 5a600d69c933ea96702129737751a75ccdec880f Mon Sep 17 00:00:00 2001 From: Ross Paterson Date: Thu, 27 May 2010 15:08:33 +0000 Subject: [PATCH] doc comment illustrating Foldable(foldr) --- Data/Foldable.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Data/Foldable.hs b/Data/Foldable.hs index ed05a16..9f7d3e9 100644 --- a/Data/Foldable.hs +++ b/Data/Foldable.hs @@ -96,7 +96,12 @@ import Array -- > foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r -- -- This is suitable even for abstract types, as the monoid is assumed --- to satisfy the monoid laws. +-- to satisfy the monoid laws. Alternatively, one could define @foldr@: +-- +-- > instance Foldable Tree where +-- > foldr f z Empty = z +-- > foldr f z (Leaf x) = f x z +-- > foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l -- class Foldable t where -- | Combine the elements of a structure using a monoid. -- 1.7.10.4