I want to split ByteString
to words like so:
import qualified Data.ByteString as BS
main = do
input <- BS.getLine
let xs = BS.split ' ' input
But it appears that GHC can't convert a character literal to Word8
by itself, so I got:
Couldn't match expected type `GHC.Word.Word8'
with actual type `Char'
In the first argument of `BS.split', namely ' '
In the expression: BS.split ' ' input
Hoogle doesn't find anything with type signature of Char -> Word8
and Word.Word8 ' '
is invalid type constructor. Any ideas on how to fix it?
ByteString
for text! UseText
instead. – OberlandByteString
? – FlailText
is unicode-friendly, so your strings will be strings in all countries.ByteString
is for binary parsing, raw memory access, and can't handle anything other than ascii or latin1. – Bergh