
15 Sep
2006
15 Sep
'06
9:51 a.m.
The problem is that, when I run it with strings containing a number more then 10 digit long, I get unexpected integers back:
*Main> runP number1 "1234567890 and the rest" [(1234567890," and the rest")] *Main> runP number1 "12345678901 and the rest" [(-539222987," and the rest")]
This has nothing to do with your parser, but with the representation you use. The Int type is bounded by Prelude> maxBound :: Int 2147483647 i.e. that's the highest value of Int you could get. So if you just write Prelude> 12345678901 :: Int -539222987 you see that you have the same "problem". The solution is to use the unbounded type Integer instead of the bounded type Int. Cheers, /Niklas