by CJefferson · 11y ago · 0 comments
Prelude> foldr + [1,2,3]
<interactive>:14:9: Couldn't match expected type ‘(a -> b -> b) -> b -> [a] -> b’ with actual type ‘[t0]’ Relevant bindings include it :: (a -> b -> b) -> b -> [a] -> b (bound at <interactive>:14:1) In the second argument of ‘(+)’, namely ‘[1, 2, 3]’ In the expression: foldr + [1, 2, 3] In an equation for ‘it’: it = foldr + [1, 2, 3]
1. + contains only special characters and must be used either as infix function (1 + 2) or be enclosed in brackets
2. You need an initial value for the accumulator. You are reducing a list to a single value, you need to start somewhere
Please, gurus of Haskell, correct me if I'm wrong, I've just recently started to learn the language