[Haskell-cafe] ByteString missing rewrite RULES (zipWith' f a = pack . zipWith f a)

Thomas DuBuisson thomas.dubuisson at gmail.com
Tue Oct 5 14:07:48 EDT 2010


(I notice ByteString still isn't under l at h.o ownership, which is good
because this way I can avoid the bureaucracy and e-mail the
maintainers directly)

The following is a Data.ByteString comment for the (non-exported)
function zipWith'
-- | (...) Rewrite rules
-- are used to automatically covert zipWith into zipWith' when a pack is
-- performed on the result of zipWith.

This implies there should be a rule:
"ByteString specialise zipWith'" forall (f :: Word8 -> Word8 -> Word8) p q .
    zipWith' f p q = pack (zipWith f p q)

But no such rule exists in the ByteString source (the inverse rule
using 'unpack' does exist).

1) Is this an omission?  Can we fix it?  It's a rather important rule
for crypto-api.
2) Can we export zipWith' so people can be explicit?  If not, can we
get the comment about the rule placed somewhere so it will make its
way to the generated Haddock documentation for general users?

3) Very different issue:
Could .Lazy export hGetN or have defaultChunkSize configurable by a
CPP/compile time macro?

If not, perhaps we could make "chunkOverhead = max 16 (2 * sizeOf
(undefined ::Int))" so it will be the same on 64 and 32 bit systems (a
128 bit boundary, nice and fast for most modern cipher algorithms,
sadly asking for it to match hash block sizes is a bit much).


More information about the Haskell-Cafe mailing list