OverloadedStrings for chars [duplicate]
Asked Answered
T

1

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?

Telluric answered 22/12, 2014 at 8:11 Comment(2)
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'Molasses
This might help: #10623924Mistrot
A
3

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

Amador answered 22/12, 2014 at 8:46 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.