Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

takeWhile1 doesn't stop on end of string #111

Open
varosi opened this issue Nov 7, 2015 · 4 comments
Open

takeWhile1 doesn't stop on end of string #111

varosi opened this issue Nov 7, 2015 · 4 comments

Comments

@varosi
Copy link

varosi commented Nov 7, 2015

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
@basvandijk
Copy link
Member

What if you place a endOfInput at the end?

@varosi
Copy link
Author

varosi commented Nov 8, 2015

I would like to match "parseClass" parser no matter if it is in the middle or at the end of input.

@googleson78
Copy link

@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.

@varosi
Copy link
Author

varosi commented Dec 16, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants