title: Haskell transforming fuction to use foldr or foldl
body: <p>I am struggling understanding foldr and foldl, what are main benefits of using either, foldl is supposed to be tail recursive, but then what is foldr, normally recursive? </p>
  
  <p>I have simple function which takes list of int and returns sum of squares between first and last element.</p>
  
  <pre><code>sumSquare :: [Int] -&gt; Int
  sumSquare xs = if length xs == 2 then  sum $  map (^2) [head xs..last xs] else error "bad input"
  </code></pre>
  
  <p>What I want to do is implement this function using foldr or foldl, I've looked through few examples, but sadly got nowhere with it.</p>
  
  <p>If someone could demonstrate how to transform this function to one using either foldr or foldl and explain process I would be grateful </p>