ByteString, zipWith', and rewrite rules

Comments on the zipWith' function inside of Data.ByteString say: -- Rewrite rules -- are used to automatically covert zipWith into zipWith' when a pack is -- performed on the result of zipWith. This is only true internally to Data.ByteString because the zipWith' function could be inlined away by GHC once that module is compiled, right? If I want "pack (zipWith xor bs1 bs2)" to be efficient then I'll have to either get zipWith' exported or write my own lower level zipWith'? If I'm wrong here then the comment needs to be moved to somewhere that will get haddockized, perhaps with zipWith. Cheers, Thomas

Thomas M. DuBuisson wrote:
Comments on the zipWith' function inside of Data.ByteString say:
-- Rewrite rules -- are used to automatically covert zipWith into zipWith' when a pack is -- performed on the result of zipWith.
This is only true internally to Data.ByteString because the zipWith' function could be inlined away by GHC once that module is compiled, right? If I want "pack (zipWith xor bs1 bs2)" to be efficient then I'll have to either get zipWith' exported or write my own lower level zipWith'?
As far as I know GHC prefers RULES to INLINE, but it's fragile. You may check with -ddump-simpl-stat.
participants (2)
-
Henning Thielemann
-
Thomas M. DuBuisson