title: Spark: Create new accumulator type won't work (Scala)
body: <p>I want to create an accumulator for lists of type List[(String, String)]. I first created the following object:</p>
  
  <pre><code>object ListAccumulator extends AccumulatorParam[List[(String, String)]] {
    def zero(initialValue: List[(String, String)]): List[(String, String)] = {
      Nil
    }
  
    def addInPlace(list1: List[(String, String)], list2: List[(String, String)]): List[(String, String)] = {
      list1 ::: list2
    }
  }
  </code></pre>
  
  <p>In the same file (SparkQueries.scala) I tried to use it within a function in my class:</p>
  
  <pre><code>val resultList = sc.accumulator(Nil)(ListAccumulator)
  </code></pre>
  
  <p>However, here my compiler complains at (ListAccumulator). The following error occurs: </p>
  
  <blockquote>
    <p>type mismatch; found : sparkMain.ListAccumulator.type required: org.apache.spark.AccumulatorParam[scala.collection.immutable.Nil.type] Note: List[(String, String)] >: scala.collection.immutable.Nil.type (and sparkMain.ListAccumulator.type &lt;: org.apache.spark.AccumulatorParam[List[(String, String)]]), but trait AccumulatorParam is invariant in type T. You may wish to define T as -T instead.</p>
  </blockquote>
  
  <p>sparkMain is the package the .scala file is in. What am I doing wrong? Is it possible the compiler doesn't know of the existence of the ListAccumulator object?</p>
  
  <p>Thanks in advance!</p>