[Haskell-cafe] ghc has problems with 'zipWith' ?

Derek Elkins ddarius at hotpop.com
Wed Dec 8 08:17:49 EST 2004

> Is it possible and senseful for a compiler to extract common
> sub-expressions? Naively I think that for a given tree of an
> expression it is efficiently possible to find all common sub-trees.
> Referential transparency would assure that equal expressions have the
> same value, so they can be replaced by the same object. E.g.  the
> example above could be automatically transformed to: 
> ms as =
>    let tmp0 = zipWith (+) (zipWith (*) as tmp1) (0:tmp1)
>        tmp1 = 1:tmp0
>    in  tmp0

It's possible and will preserve semantics, but isn't always an


More information about the Haskell-Cafe mailing list