
On Fri, Aug 13, 2010 at 10:01 PM, Dan Doel
On Friday 13 August 2010 8:51:46 pm Evan Laforge wrote:
I have an app that is using Data.Text, however I'm thinking of switching to UTF8 bytestrings. The reasons are that there are two main things I do with text: pass it to a C API to display, and parse it. The C API expects UTF8, and the parser libraries with a reputation for being fast all seem to have bytestring inputs, but not Data.Text (I'm using unpack -> parsec, which is not optimal).
You should be able to use parsec with text. All you need to do is write a Stream instance:
instance Monad m => Stream Text m Char where uncons = return . Text.uncons
Then this should be on a 'parsec-text' package. Instances are always implicitly imported. Suppose packages A and B define this instance separately. If package C imports A and B, then it can't use any of those instances nor define its own. Cheers! =) -- Felipe.