Data.Text vs String

My unqualified guess is that most library writers don’t want to add more dependencies than necessary. Since strings are part of literally every Haskell distribution (it’s part of the language standard!), it is a lot easier to get adopted if you use strings and don’t require your users to sort out Text distributions from hackage.

It’s one of those “design mistakes” that you just have to live with unless you can convince most of the community to switch over night. Just look at how long it has taken to get Applicative to be a superclass of Monad – a relatively minor but much wanted change – and imagine how long it would take to replace all the String things with Text.


To answer your more specific question: I would go with String unless you get noticeable performance benefits by using Text. Error messages are usually rather small one-off things so it shouldn’t be a big problem to use String.

On the other hand, if you are the kind of ideological purist that eschews pragmatism for idealism, go with Text.


* I put design mistakes in scare quotes because strings as a list-of-chars is a neat property that makes them easy to reason about and integrate with other existing list-operating functions.

Leave a Comment