title: Functional Programming Solution
body: <p>I'm kind of newbie in FP and Haskell and trying to solve some trivial tasks. E.g we have array of products:</p>
  
  <pre><code>data Product = Product String Int
  let apple = Product "Apple" 15
  let pineapple = Product "Pineapple" 20
  let products = [apple, pineapple]
  </code></pre>
  
  <p>The tasks:</p>
  
  <ul>
  <li>calculate total price of products (this is simple, e.g I can use foldl)</li>
  <li>calculate total price if every third apple has a discount 0.5</li>
  <li>calculate total price if the pineapple is free in case of buying each two apples.</li>
  </ul>
  
  <p>In traditional imperative programming this is quite simple, e.g I can use different calculation strategies for this.
  How can I solve this in Haskell? Should I use State monad or there are other solutions? Could you please provide some algorithm steps or code?</p>