Text 与 ByteString
由于 String 仅仅只是 [Char] 的别名,所以速度很慢.以下两种类型可以用于替代 String
Data.Text表示 a sequence of Unicode CharsData.ByteString表示 a sequence of Bytes,通常用于处理二进制数据
也有 strict 和 lazy 之分:
The strict
Texttype requires that an entire string fit into memory at once. The lazyTexttype is capable of streaming strings that are larger than memory using a small memory footprint… Each module provides an almost identical API…
这两个类型都有 pack, unpack 方法完成与 String 之间的互相转化
即使载入同一个字符串,Text.Lazy 有时和 Text 也会不相等,需要用 fromStrict, toStrict 进行转化.