I know Data.Text is a much more efficient way of storing string data than String = [Char]. However, it seems that a number of functions I see in libraries expect a String passed to them. A linked list of Chars seems very inefficient to read, considering pointers will take up more space than the string itself. Besides list fusion (which may not always be possible), are there any optimizations that GHC makes to the storage of [Char]‘s, and does it apply similar principles to other lists?
I know Data.Text is a much more efficient way of storing string data than
Share
The reason why all the base library functions use
Stringinstead of a more efficient type is that the text library needed forTextis not part of the base library. However, the text library provides its own variants of the various input/output functions. You can find them inData.Text.IO.Also note that for efficient I/O you would normally use one of the modern abstractions likes conduits, iteratees or pipes.