Skip to content

Instantly share code, notes, and snippets.

@funrep
Last active January 2, 2016 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funrep/8301310 to your computer and use it in GitHub Desktop.
Save funrep/8301310 to your computer and use it in GitHub Desktop.
Weird behaviour by the Parser params
params :: Parser Params
params = do
ps <- takeWhile (notInClass ":\r") `sepBy` space
@funrep
Copy link
Author

funrep commented Jan 7, 2014

*Tob.Parser> maybeResult $ parse params $ T.pack "foo bar xyz:"
Just ["foo bar xyz"]
*Tob.Parser> maybeResult $ parse params $ T.pack "foo bar xyz :"
Just ["foo bar xyz "]
*Tob.Parser> maybeResult $ parse params $ T.pack "foo bar xyz \r"
Nothing
*Tob.Parser> maybeResult $ parse params $ T.pack "foo bar xyz\r"
Nothing

@funrep
Copy link
Author

funrep commented Jan 7, 2014

Behaviour I want:

> maybeResult $ parse params $ T.pack "foo bar xyz :"
Just ["foo", "bar", "xyz"]
> maybeResult $ parse params $ T.pack "foo bar xyz\r"
Just ["foo", "bar", "xyz"]

@funrep
Copy link
Author

funrep commented Jan 7, 2014

How can this NOT work? o.o

*Tob.Parser> let p = takeWhile (/= '\n') `sepBy` space
*Tob.Parser> maybeResult $ parse p $ T.pack "hahah ahahah ahahah\n"
Nothing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment