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 chars, 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 strings, 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 strings. example, various case-folding , substring-related functions. while variants of these work on strings provided, there's little incentive since text versions readily available.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -