As Nikita Volkov mentioned in his question Data.Text vs String I also wondered why I have to deal with the different String implementations type String = [Char]
No.
Haskell doesn't have implicit coercions for technical, philosophical, and almost religious reasons.
As a comment, converting between these representations isn't free and most people don't like the idea that you have hidden and potentially expensive computations lurking around. Additionally, with strings as lazy lists, coercing them to a Text
value might not terminate.
We can convert literals to Text
s automatically with OverloadedString
s by desugaring a string literal "foo"
to fromString "foo"
and fromString
for Text
just calls pack
.
The question might be to ask why you're coercing so much? Is there some why do you need to unpack
Text
values so often? If you constantly changing them to strings it defeats the purpose a bit.