views:

56

answers:

1

Hi i'm facing the following problem, i have to re-write an existant code to improve his performances. the old version was using a parser defined like this :

newtype Parser Char a = Parser {runParser :: [Char] -> [(a,[Char])]}

to parse lines from files. but it was too slow and required a lot of memory to achieve the computation upon lines. To improve that code, I decided to use Data.ByteString.Lazy.Char8 instead of String, but i don't know how to deal with the parser, is it possible to defined a parser in this way ?

newtype Parser Char a = parser {runParser :: ByteString -> [(a,ByteString)]} ?

or, is there any parser package dedicate to these kind of work ?

thanks to reply

+2  A: 

attoparsec and Parsec 3 both have interfaces targeting lazy ByteStrings.

(And of course, it is possible to define a parser in that way, but I think you mean

newtype Parser a = Parser {runParser :: ByteString -> [(a,ByteString)]}

)

KennyTM