[Haskell-cafe] [Q] A typing problem
Didier Verna
didier at lrde.epita.fr
Wed Apr 13 06:03:00 EDT 2005
Hi !
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)
But this gives a typing error:
ERROR "src/ssq4.hs":2 - Type error in application
*** Expression : foldr1 f (map m)
*** Term : map m
*** Type : [b] -> [b]
*** Does not match : [a]
What can I do to get what I want ?
Thanks.
--
Didier Verna, didier at lrde.epita.fr, http://www.lrde.epita.fr/~didier
EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bicêtre, France Fax.+33 (1) 53 14 59 22 didier at xemacs.org
More information about the Haskell-Cafe
mailing list