Haskell How to convert Char to Word8
In case you really need Data.ByteString (not Data.ByteString.Char8), you could do what Data.ByteString itself does to convert between Word8 to Char:
import qualified Data.ByteString as BS
import qualified Data.ByteString.Internal as BS (c2w, w2c)
main = do
input <- BS.getLine
let xs = BS.split (BS.c2w ' ') input
return ()
The Data.ByteString.Char8 module allows you to treat Word8
values in the bytestrings as Char
. Just
import qualified Data.ByteString.Char8 as C
then refer to e.g. C.split. It's the same bytestring under the hood, but the Char
-oriented functions are provided for convenient byte/ascii parsing.