Reading through this informative, well-written article on Parser Combinators, I see this code:
class DisParser[+A](left: Parser[A], right: Parser[A]) extends Parser[A] {
def apply(s: Stream[Character]) = left(s) match {
case res: Success => res
case _: Failure => right(s)
}
}
When I try to compile this code, I get:
Parser.scala:19: error: class Success takes type parameters
case res: Success => res
^
one error found
Given the signature of Parser
:
case class Success[+A](value: A, rem: Stream[Character]) extends Result[A]
How can I change the case res: Success => res
line to give Success
a proper type parameter?