3 ms·
There are couple of implementarion of strings: * String - this is default, it is list of characters and it was a mistake. * ByteString and LazyByteString - thi
by mic47 7y ago
There are couple of implementarion of strings:
* String - this is default, it is list of characters and it was a mistake.
* ByteString and LazyByteString - this represents array of 8bit characters. Performant but does not handle encodings
* Text and LazyText - this is what you want to use when yiu work with text, since it represent text in unicode.
There is mess in these types. s9me libraries are using different types, so you might have to convert between those and it can be confusing, and the conversion apis are not unified. But if you manage in your project consistently use single type (say Text), then you'll actually have a great time working with strings. Its problem if you want to quickly mash together few libraries that does not use same types, since it get messy.
Reason for this is mostly historic.
- marcosdumay 7y ago> ByteString and LazyByteString - this represents array of 8bit characters Not exactly. ByteString has no relation at all with text or characters. It represents a sequence of bytes, AKA binary data. I imagined I would hear complaints about too many text types when I made that question, but it sounded like the GP had a different complaint. The library mess is real, but it's improving quickly and it's a bad reason to decide Haskell is a bad language to deal with text. It's throwing a lot of great stuff out just because of a minor inconvenient. And by the way, one of the best things on Haskell is that you can defined a lot more text types. For example, my current project has types for internal identifiers, HTML, HTML form values, JS, and SQL, they are all text but I can always be sure things are properly encoded.