[Haskell-cafe] ByteString, zipWith', and rewrite rules

Henning Thielemann lemming at henning-thielemann.de
Tue Jul 13 07:39:46 EDT 2010


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.



More information about the Haskell-Cafe mailing list