[Haskell-cafe] [Q] A typing problem

Henning Thielemann lemming at henning-thielemann.de
Wed Apr 13 08:11:02 EDT 2005


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

?


More information about the Haskell-Cafe mailing list