[Haskell-cafe] Please explain the Lazy type differences
cdsmith at gmail.com
Mon Jan 17 05:58:49 CET 2011
On Sun, 2011-01-16 at 21:39 -0700, Roderick Ford wrote:
> I wrote this little clip, and haven't been able to figure out why the
> L.ByteString is different type than
> Data.ByteString.Internal.ByteString, or if I am just doing everything
> wrong here.
This is definitely confusing. Types called ByteString are exported from
all of the following modules:
IIRC, the first three are all the same type, and the last three are all
the same type. But the types from the first and last groups are NOT the
You typically import ByteString qualified anyway... and it's normal to
import any of the first set with qualfied name "B", "S", or "SB". The
last set is typically imported qualified as "L" or "LB". Here, the S
and L stand for "strict" and "lazy".
If you need to convert between them, there is:
L.toChunks :: L.ByteString -> [S.ByteString]
L.fromChunks :: [S.ByteString] -> L.ByteString
S.concat :: [S.ByteString] -> S.ByteString
Keep in mind that concatenating very large, or a very large number of,
strict ByteStrings can be expensive.
More information about the Haskell-Cafe