The documentation for ByteString gives the following code example:
breakByte :: Word8 -> ByteString -> (ByteString, ByteString)
breakByte 'c' "abcd"
However when I write the same I get the following error (ideone):
Couldn't match expected type `GHC.Word.Word8'
with actual type `Char'
Of course 'c'
is a Char
, not Word8
. Presumably they're using some extension which allows a fromInteger
style function to work automatically on Char
literals, but I'm not sure what. {-# LANGUAGE OverloadedStrings #-}
doesn't seem to make any difference.
Just import the Char8 versions of the modules. These do the byte conversions. Note that this is for 8 bit characters. So don't try putting unicode data into it.