While the general opinion of the Haskell community seems to be that it's always better to use Text
instead of String
, the fact that still the APIs of most of maintained libraries are String
-oriented confuses the hell out of me. On the other hand, there are notable projects, which consider String
as a mistake altogether and provide a Prelude
with all instances of String
-oriented functions replaced with their Text
-counterparts.
So are there any reasons for people to keep writing String
-oriented APIs except backwards- and standard Prelude-compatibility and the "switch-making intertia"?
Are there possibly any other drawbacks to Text
as compared to String
?
Particularly, I'm interested in this because I'm designing a library and trying to decide which type to use to express error messages.
String
is just an alias for a list ofChar
s, it's natural that it has different performance characteristics from a monolithic data, whichText
is. Both types are not at all of compiler's concern, since they aren't primitive and are defined in libraries. – Nikita Volkov