Class X Takes Types Parameters

parser-generator, scala

Solution

Which `Success` are you using? This one (Success from Parsers package) or this one (Success from util)? Both take type parameters, so you'll need to put it as

res @ Success(_, _) =>

otherwise you'll have to deal with the erasure warning.

Problem

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?

Original source

Related problems