6

The hackage documentation for ByteString contains this example:

split :: Word8 -> ByteString -> [ByteString]
split '\n' "a\nb\nd\ne" == ["a","b","d","e"]

It's as if '\n' is converted to a Word8, but LANGUAGE OverloadedStrings seems only to work on strings, not chars. What extension to I need to include for the example code to work?

Don Stewart
  • 137,316
  • 36
  • 365
  • 468
Clinton
  • 22,361
  • 15
  • 67
  • 163
  • If I try that example, it results in an error. `Couldn't match expected type 'Word8' with actual type 'Char' In the first argument of 'split', namely '\n'` – Cirdec Dec 22 '14 at 08:22
  • 2
    This might help: http://stackoverflow.com/questions/10623424/haskell-how-to-convert-char-to-word8 – shree.pat18 Dec 22 '14 at 08:42

1 Answers1

3

bytestring supports a cheap and cheerful Latin1 view of the bytes. You can import Data.ByteString.Char8 to get that view.

Don Stewart
  • 137,316
  • 36
  • 365
  • 468