I would like to replace a substring with a string in Haskell, without using external libraries, and, if it is possible, with good performance.
I thought about using the Data.Text replace functions, but I don't want to port my entire program to use the Text type instead of Strings. Would packing the String into a Text value, then replacing what I wanted to, then unpacking that Text value to a String be slow on a lot of Strings?
StringwithText.Textinstead ofStringis unlikely to be difficult, just tedious. There are corner cases concerning APIs usingStrings without the option to useText/ByteString, but for the most part it's just a matter of changing the type in one place and then correcting the type errors that crop up elsewhere.Data.Text, usereplace