I have this snippet of Scala code:
def prologList(l: List[ScalaObject], sep: String) =
"[" + (if (l isEmpty) "" else l.reduceLeft(_ + sep + _)) + "]"
def neighbors(s: State) = prologList(trans(s).toList, ", ")
def labels(s: State) = prologList(labeling(s).toList, ", ")
The next-to-last line compiles fine, but on the last line I get the error
Found
List[Char], requiredList[ScalaObject]
(labeling has the type Map[State, Set[Char]].)
I'm a bit surprised, since 1) I thought that List[Char] could be seen as a subtype of List[ScalaObject] (as opposed to Java), and 2) the line above the last line compiles! (trans has type Map[State, Set[State]] though...)
The question is obvious, what am I doing wrong, and how do I fix it?