Your parser should return a value of type Result[A] , as its type definition says (basically the parser is a function from character streams to the result of parsing) .:
trait Parser[+A] extends (Stream[Character]=>Result[A])
So, you have two options:
case res@Success (_,_) => res
This is a match for the case class returned.
case res:Success[_] => res.asInstanceOf[Success[A]]
It matches the return type (using the instanceof operation). This is why you should use (you cannot match a type parameter without typetag value, since the JVM really erases the styles).
Both are valid in your case, in the first case you omitted the type parameter (this was your original error). In your attempt to follow @wheaties advice, you made a syntax error somewhere in your code, but this is really the best way to go here.
source share