[Haskell-beginners] parsec question
Stephen Tetley
stephen.tetley at gmail.com
Mon Jul 19 08:10:41 EDT 2010
On 19 July 2010 12:05, David Virebayre <dav.vire+haskell at gmail.com> wrote:
> Note that he doesn't want "123456" to parse as the integer 123456, but
> rather as the list of digits [ 1,2,3,4,5,6 ].
Fair enough, I'd swap /digitToInt/ for read though...
digit1 :: Parser Int
digit1 = liftM digitToInt digit
digitList :: Parser [Int]
digitList = many digit1
digitToInt should do less work than read - running read is effectively
re-parsing the digits you have already parsed.
Best wishes
Stephen
More information about the Beginners
mailing list