I have to parse a string with syntax
lazy val expr: Parser[Term ~ Option[<recursion>]] = term ~ opt(expr)
You see, it uses itself to parse subexpressions. But what does this type result in? In order to reproduce the problem, I created a somewhat similar problem
def quine(depth: Int, result: (Any, Option[Any])): (Any, Option[Any]) =
if (depth == 0) result else {quine(depth - 1, (depth, Some(result)))}
quine(5, (true, None))
As you see, I used Any
since I do not know how to give exact type.
The lists somehow define proto type List[A]
, extended by Cons[A](head: A, tail: List[A])
and some magic Nil
. This allows the list to recur somehow. But, what should I do in my case?