FAQ Database Discussion Community


attoparsec: succeeding on part of the input instead of failing

haskell,attoparsec
I have an attoparsec parser, and tests for it, what annoys me is that if I comment part of the parser and run the tests, the parser doesn't return Left "parse error at line ..." but instead I get Right []. Note that I'm using parseOnly to make it clear...

How can I parse fixed-length, non-delimited integers with attoparsec?

parsing,haskell,integer,attoparsec
I'm trying to parse two integers from 3 characters using attoparsec. A sample input might look something like this: 341 ... which I would like to parse into: Constructor 34 1 I have two solutions that work but which are somewhat clunky: stdK :: P.Parser Packet stdK = do P.char...

Conduit and Attoparsec - extracting delimited text

haskell,conduit,attoparsec
Say I have a document with text delimited by Jade-style brackets, like {{foo}}. I've written an Attoparsec parser that seems to extract foo properly: findFoos :: Parser [T.Text] findFoos = many $ do manyTill anyChar (string "{{") manyTill letter (string "}}") Testing it shows that it works: > parseOnly findFoos...