> Could anyone tell me why "longTest", which uses a parser "p" which I
> _thought_
> was tail-recursive gives "Control Stack overflow"?
> (Program is attached).
Here is your definition of p:
> p s = do c <- item
> p (c:s)
> +++ return s
I do not think this is the definition you want. The argument to the
recursive call is longer than the argument to the call. For example, if you
try p "abc", it will then try p "aabc", p "aaabc", ...
However, even if you fixed that problem, your p will just end up accepting
any string which has the same length as its argument. Maybe what you want is
the combinator "string", which is defined in ParseLib.
As for tail recursion, it isn't tail-recursive. After a recursive call
returns, there is still a continuation because of the (+++). For any
reasonable language, I think, you will not be able to write tail-recursive
parsers using the ParseLib combinators because they use backtracking.
--fac