[Haskell-cafe] Re: String vs ByteString

Dan Doel dan.doel at gmail.com
Fri Aug 13 21:01:10 EDT 2010


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

-- Dan


More information about the Haskell-Cafe mailing list