-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
spanP is defined as below:
spanP :: String -- description
-> (Char -> Bool) -- predicate
-> Parser String
spanP desc = many . parseIf descUsing many here instead of some makes it so matching nothing or even getting an empty input is not an error.
How to reproduce
> ghci Main.hs
λ> runParser (spanP "integer" isDigit) $ Input 0 ""
Right (Input {inputLoc = 0, inputStr = ""},"")
λ> runParser (spanP "integer" isDigit) $ Input 0 "abcde"
Right (Input {inputLoc = 0, inputStr = "abcde"},"")
As of now spanP creates a parser which does not return an error on parse failure of string.
I'm not sure if that is the intended behavior but that might bring some trouble later on.
N.B: See many / some documentation here.
I'm aware that for removing optional whitespaces and such the many is required. Maybe there should be a spanP' that uses some instead for the other cases.
Metadata
Metadata
Assignees
Labels
No labels