Compile with -O2 .
... ok this only works in certain cases.
In your unoptimised assembly, unoptimised first create two vectors created using fromList . Since vectors are strict (and non-aligned hyperstrings), this will not work, since you cannot build a vector of infinite size.
If you compile -O2 , stream fusion comes into play. Now all intermediate vectors (those fromList ) are not created at all. Since zipWith stops after completing the first data feed, you now have a completion function.
But in general: do not use endless deliveries with vector operations, the semantics of your functions now depend on your level of optimization, which is bad.
The original streaming fusion paper describes the transition from lists to streams and back to lists again. For simplicity, you can think of lists as vectors (since vectors add a bunch of additional material, such as memory allocation, monadic behavior, etc.).
In general (and much simplified), rewrite rules are used for the internal representation of vectors as streams, which allows merging, and streams are then returned to vectors.
source share