<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000"><font size="+1">f1 = (zipWith ($)) . (mapĀ (*)) <br>
<br>
f2 = sum</font></div></blockquote><div><br>First, f1 would be clearer as zipWith (*).<br><br>Second, look at the type of (.):<br><br>(.) :: (b -> c) -> (a -> b) -> (a -> c)<br><br>Notice that (b -> c) and (a -> b) each take one argument, but f1 takes two arguments. That's why using (.) with f1 doesn't work.<br>
<br>You can do what you want by uncurrying f1 so it takes only one argument, which makes it easier to compose. You can then re-curry the result after you do the composition.<br><br>f1 :: [Integer] -> [Integer] -> [Integer]<br>
uncurry f1 :: ([Integer], [Integer]) -> [Integer]<br>f2 . uncurry f1 :: ([Integer], [Integer]) -> Integer<br>curry (f2 . uncurry f1) :: [Integer] -> [Integer] -> Integer<br><br>I'm sure there are shorter versions that use more than just (.), curry, and uncurry.</div>
</div>