Back in the day, everybody used to do text processing with String
. But then some folks pointed out that this is actually very, very inefficient, and the ByteString
package was born.
ByteString
is great for handling binary data. But soon people pointed out that ByteString.Char8
is actually a massive kludge, and what you really want is real Unicode handling for external data. And with that, approximately thirty similar but incompatible Haskell packages for dealing with packed Unicode strings were born. And none of them could really get any traction, because... well, thirty is way too many!
My question: Has this problem been fixed yet? In other words, has the community settled on one package for doing this job? And if so, which one is it?
I believe that the current gold standard is Data.Text, which you can install with
$ cabal install text
and which you should import qualified as
import qualified Data.Text as T
You create Text
values in your code either by explicitly casting from String
, as in
>> let str = T.pack "Hello, world"
or by using the OverloadedStrings
language extension
>> :set -XOverloadedStrings
>> let str = "Hello, world" :: Text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With