[Haskell-cafe] ByteString/parsec

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


HI,

I want to efficiently parse  a large collections of files.

The files are in the format :

example title
TITLE
author name
AUTHOR
some lines with summary here
SUMMARY
the real text
TEXT
a list of links
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

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