Really, I'd like to figure out the more general solution of composing a fold with a zipwith in a single function point free.
zWMult :: Num c => [c] -> [c] -> [c]
zWMult = zipWith (*)
foldPl0 :: Num c => [c] -> c
foldPl0 = foldl (+) 0
I get the correct solution when I use arguements
dPr x y = foldPl0 (zWMult x y)
dPr x y = foldPl0 $ zWMult x y
But have no idea how to naturally compose these without arguments. Both these fail:
Prelude> :{
Prelude| let dPr1 :: Num c => [c] -> [c] -> c
Prelude| dPr1 = fPl0 $ zWMult
Prelude| :}
<interactive>:171:19:
Couldn't match expected type ‘[[c] -> [c] -> c]’
with actual type ‘[Integer] -> [Integer] -> [Integer]’
Relevant bindings include
dPr1 :: [c] -> [c] -> c (bound at <interactive>:171:5)
Probable cause: ‘zWMult’ is applied to too few arguments
In the second argument of ‘($)’, namely ‘zWMult’
In the expression: fPl0 $ zWMult
Prelude> :{
Prelude| let dPr1 :: Int c => [c] -> [c] -> c
Prelude| dPr1 = foldPl0 $ zWMult
Prelude| :}
<interactive>:11:13:
‘Int’ is applied to too many type arguments
In the type signature for ‘dPr1’: dPr1 :: Int c => [c] -> [c] -> c
As well as
dPr2 = foldPl0 . zWMult
Edit: Cool, one should cross reference this post if you want a more complete understanding of the solution below. What does (f .) . g mean in Haskell?