string - benefits of Data.Text -
what benefits of importing data.text on haskell's native string functions?
ghci$> drop 3 "abcdefg" > "defg" ghci$> import qualified data.text t > t.drop 3 $ t.pack "abcdefg" > "defg"
etc. many other methods (if not all) provided data.text provided out box standard library. in addition, use string data.text, have pack/unpack string text. why want use data.text?
data.text
more space-efficient. haskell's native string
equivalent linked list of char
s, means has high space overhead moderately-sized chunks of text.
data.text
more performant string
. because string
linked list, whereas text
memory array (or several memory arrays in lazy variant), provides better memory locality. text
can interface native system libraries (e.g. io) more efficiently string
s, need go through intermediate buffer. programs lot of io (reading/writing files), speedup can order of magnitude or more.
finally, data.text
provides text-specific functions aren't readily available native string
s. example, various case-folding , substring-related functions. while variants of these work on string
s provided, there's little incentive since text
versions readily available.
Comments
Post a Comment