Data.bytestring
String is a synonym for [Char], and there is a performance problem with the inertia of list on use.
When working with large binary files, you can use ByteString instead of String.
The ByteString contains the Lazy module Data.ByteString.Lazy and the Strict module data.bytestring.
Where the Lazy module uses chunks (64K data blocks) internally.
Prelude> import qualified Data.ByteString.Lazy as BPrelude B> import qualified Data.ByteString as SPrelude B S> B.pack [99,97,110]"can"Prelude B S> B.fromChunks [S.pack [40,41,42], S.pack [43,44,45], S.pack [46,47,48]]"()*+,-./0"Prelude B S> B.cons 85 $ B.pack [80,81,82,84]"UPQRT"Prelude B S> foldr B.cons' B.empty [50..60] "23456789:;<"
Data.text
When working with large text files, you can use text instead of String.
Text is a Unicode-friendly string type.
Text contains the Lazy module Data.Text.Lazy and Strict module DATA.TEXT.
Where the chunks is used internally by the Lazy module.
Prelude> import qualified Data.Text.Lazy as TPrelude T> :t T.pack "abc"T.pack "abc" :: T.TextPrelude T> T.replace (T.pack "a") (T.pack "b") (T.pack "aXaXaX")"bXbXbX"Prelude T> T.splitOn (T.pack "a") (T.pack "aXaXaX")["","X","X","X"]
Haskell Language Learning Note (ByteString Text)