[Haskell-cafe] bytestring

Don Stewart dons at galois.com
Sat Jan 5 00:37:41 EST 2008

2.5 years after the first release, bytestring is now available
on hackage,


Changes since the 0.9 release include:

      * support for bytestring literals (use -XOverloadedStrings)
      * make Data.ByteString.Lazy.Char8.lines lazier
      * fixes Handle resource leak in getContents/readFile
      * faster isSpace operations
      * performance improvements

The most notable change is the instance IsString for strict and
lazy bytestrings, enabling bytestrings to be written as direct string
literals, without needing 'pack'.

That is, the following is valid:

    import Data.ByteString.Char8

    main = print ("abcdef" :: ByteString)

(and the compile will even turn the pack into a no-op at compile time).
Or, using the (soon to be released pcre-light package), bytestring
regex literals can be written as:

    compile "a(.*)b"


    compile :: ByteString -> Either String Regex

With -XOverloadedStrings, the 'pack'for the regex is inferred.

-- Don & Duncan

More information about the Haskell-Cafe mailing list