Range takes no type parameters, expecting one

#1

Can someone help me understand this error message? If Range takes no type parameters, why is it expecting one?

Error:(52, 49) Range takes no type parameters, expected: one
  implicit val rangeTreeReducable:TreeReducable[Range] = new TreeReducable[Range] {

Here is the offending code

object TreeReducable {
  ...
  implicit val rangeTreeReducable:TreeReducable[Range] = new TreeReducable[Range] {
    override def foldLeft[B](m: Range)(z: B)(op: (B, Int) => B):B = m.foldLeft(z)(op)
  }
}
#2

Ah, that’s interesting. My best guess is that the cryptic error message is trying to say that TreeReducable expects its type parameter to be higher-order – a type that itself takes a type parameter. But Range doesn’t – it’s a first-order type.

That said – do you need this? Range is a descendant of TraversableOnce, and it looks to me like you can simply call doReduce on it using that…

#3

Good point. It’s a bit hard for me to pinpoint the exact problem. Perhaps Range is a white herring.
The case that actually doesn’t work is:

(1 to 100).par.doReduce(0)(identity,_+_)

with this error. I was looking at parent types and perhaps wrongly supposed that ParRange <: Range

Error:(68, 30) value doReduce is not a member of scala.collection.parallel.immutable.ParRange
      assert(sum == nums.par.doReduce(0)(id,_ + _))