title: Understanding FoldLeft in ScalaZ
body: <p>I'm reading some articles about <code>ScalaZ</code> and have a question about understanding it. In this <a href="http://eed3si9n.com/learning-scalaz/sum+function.html" rel="nofollow noreferrer"><strong><em>article</em></strong></a>, we generalize the sum function, to abstract away the type to be summed.</p>
  
  <pre><code>def sum[T](xs: List[T])(implicit m: Monoid[T]) = //...
  </code></pre>
  
  <p>Where </p>
  
  <p>trait Monoid[A] is defined as follows:</p>
  
  <pre><code>trait Monoid[A] {
    def mappend(a1: A, a2: A): A
    def mzero: A
  }
  </code></pre>
  
  <p>Yes, this is pretty clear. Monoid here corresponds to the <a href="https://en.wikipedia.org/wiki/Monoid" rel="nofollow noreferrer">algebraic monoid structure</a>. Now in this <a href="http://eed3si9n.com/learning-scalaz/FoldLeft.html" rel="nofollow noreferrer"><strong><em>article</em></strong></a> it abstracts over lists. To do this we define the following trait:</p>
  
  <pre><code>trait FoldLeft[F[_]] {
    def foldLeft[A, B](xs: F[A], b: B, f: (B, A) =&gt; B): B
  }
  object FoldLeft {
    implicit val FoldLeftList: FoldLeft[List] = new FoldLeft[List] {
      def foldLeft[A, B](xs: List[A], b: B, f: (B, A) =&gt; B) = xs.foldLeft(b)(f)
    }
  }
  </code></pre>
  
  <p>So now we can define the sum function as follows:</p>
  
  <pre><code>def sum[M[_]: FoldLeft, A: Monoid](xs: M[A]): A = {
    val m = implicitly[Monoid[A]]
    val fl = implicitly[FoldLeft[M]]
    fl.foldLeft(xs, m.mzero, m.mappend)
  }
  </code></pre>
  
  <p>I'm not a theory category expert, but it looks like Applicative functor to me. Is that correct? Can we provide such similarity to category theory.</p>