views:

427

answers:

2

I've managed to use Parsec to parse a String, but cannot manage to do the same with a ByteString.

How can I make Parsec work with ByteStrings without manually converting them to Strings?

I get the feeling this isn't hard to accomplish. Am I wrong? (I'm new to Haskell. ^^)

Thanks!

+5  A: 

Just import the Parser type from Text.Parsec.ByteString or Text.Parsec.ByteString.Lazy, instead of from Text.Parsec.String.

sth
+3  A: 

Hi,

the answer actually depends on the version of Parsec you are using. If you are using version 3.0 or later then yes. For version 2.x.x I don't think you can.

http://hackage.haskell.org/packages/archive/parsec/3.0.1/doc/html/Text-Parsec-ByteString.html

Cheers

edit: The Parsec that STH suggest (Text.Parsec.ByteString) is actually version 3.0 the previous version 2.x.x is located in Text.ParserCombinators.Parsec.

JFT
Oh, then I seem to currently lack the newest version, and have been using the older one. I will upgrade. Thank you both!
liszt