show vs. Data.ByteString.Char8.unpack for ByteString

Hi, What is the difference between show and unpack when the function arguments are of ByteString type? I thought they are the same, but they are not interchangeable at compile time. Thanks, Hong

Am Donnerstag 04 Februar 2010 21:46:39 schrieb Hong Yang:
Hi,
What is the difference between show and unpack when the function arguments are of ByteString type? I thought they are the same, but they are not interchangeable at compile time.
Thanks,
Hong
If you're using Data.ByteString, unpack has type ByteString -> [Word8] unpack and show are the same (perhaps excepting efficiency) if you use Data.ByteString.Char8 (ditto for Data.ByteString.Lazy[.Char8]).

Hong, 'show' of a ByteString will put quotes around the text and lots of \ for escaping certain characters, whereas unpack will translate each byte one-to-one to a Char. Steve Hong Yang wrote:
Hi,
What is the difference between show and unpack when the function arguments are of ByteString type? I thought they are the same, but they are not interchangeable at compile time.
Thanks,
Hong
------------------------------------------------------------------------
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (3)
-
Daniel Fischer
-
Hong Yang
-
Stephen Blackheath [to Haskell-Beginners]