You should know that ByteString really bad for things like iterating over them, but better for Concatation, etc.
If you want to work with ByteStrings, you need to convert String to ByteString, just do something like
import Data.ByteString.Lazy as B
and stick with B before every function that works with them - most functions for String also exist for ByteString . Please note: you need to convert the strings you use in ByteString with some features.
If you use Data.ByteString.Lazy.Char8 , you can easily use pack , but all characters greater than 255 will be truncated. In addition, this type is more suitable for binary data and safe memory.
Edit:. You must use package text if you want to work with text strings. Look here for more details.
source share