[Haskell-cafe] ByteString/parsec

Pieter Laeremans pieter at laeremans.org
Tue Nov 11 10:38:06 EST 2008


I want to efficiently parse  a large collections of files.

The files are in the format :

example title
author name
some lines with summary here
the real text
a list of links

I want to use "ByteString" here, but which library should I use to
parse ? "attoparsec" or "bytestringparser",
both export the same interface.

When I use one of these I thaught it would be nice to write something
like this :

fileParser :: Parser Content
fileParser = do
    title <- manyTill getInput  (string . pack "\nTITLE\n")
    author <- manyTill getInput (string. pack "\nTITLE\n")
    return Content title author ...

But this doesn't work.

Even on a small example :

 parseTest (manyTill getInput (string $ pack "SPLIT")  (pack "split
the text at SPLIT part two")

I get a stack overflow.  Obviously I'm not understanding something here.
Are there any good examples of open source projects which parse
ByteString data ?

thanks in advance,


Pieter Laeremans <pieter at laeremans.org>

"The future is here. It's just not evenly distributed yet."  W. Gibson

More information about the Haskell-Cafe mailing list