attoparsec
attoparsec copied to clipboard
takeWhile1 doesn't stop on end of string
I have this code:
parseClass :: Parser Text
parseClass = do
string "Class" <|> string "class"
skipSpace
takeWhile1 isAlpha
When I call it in GHCi I got this results:
*Lib> maybeResult . parse parseClass' $ (pack "Class Test ")
Just "Test"
*Lib> maybeResult . parse parseClass' $ (pack "Class Test")
Nothing
What if you place a endOfInput at the end?
I would like to match "parseClass" parser no matter if it is in the middle or at the end of input.
@varosi
maybeResult converts Partial values to Nothings - this is intended behaviour. You need to feed it an empty input (empty string) in order for the Partial to turn into a Done so that maybeResult will return a Just.
Thanks! На ср, 12.12.2018 г., 15:25 ч. Georgi Lyubenov [email protected] написа:
@varosi https://github.com/varosi maybeResult converts Partial values to Nothings - this is intended behaviour. You need to feed it an empty input (empty string) in order for the Partial to turn into a Done so that maybeResult will return a Just.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bos/attoparsec/issues/111#issuecomment-446587019, or mute the thread https://github.com/notifications/unsubscribe-auth/AFxXht47g-DDK56qwrUGHWYCjpMDn8Opks5u4QPTgaJpZM4Gd666 .