
13 Apr
2005
13 Apr
'05
8:11 a.m.
On Wed, 13 Apr 2005, Didier Verna wrote:
I'm trying to write a function that combines folding and mapping. This function would take two arguments (a folding function and a mapping function), and would return a function of one argument (a list of 'a''s) returning a 'a'.
The idea is to write something like sumsquare = foldmap (+) square
Here's what I write:
foldmap :: (c -> c -> c) -> (c -> c) -> (c -> c -> c) foldmap f m = foldr1 f (map m)
Do you mean foldmap :: (b -> b -> b) -> (a -> b) -> [a] -> b foldmap f m = foldr1 f . map m ?