[Haskell-cafe] Stream-fusion without the lists

Reiner Pope reiner.pope at gmail.com
Wed May 13 05:27:05 EDT 2009


2009/5/13 Don Stewart <dons at galois.com>:
> rl:
>> On 12/05/2009, at 14:45, Reiner Pope wrote:
>>
>>> The Stream datatype seems to be much better suited to representing
>>> loops than the list datatype is. So, instead of programming with the
>>> lists, why don't we just use the Stream datatype directly?
>>
>> I think the main reason is that streams don't store data and therefore
>> don't support sharing. That is, in
>>
>> let xs = map f ys in (sum xs, product xs)
>>
>> the elements of xs will be computed once if it is a list but twice if it
>> is a stream.
>>
>
> The other issue is reminding developers to preserve stream invariants,
> so as not to break the heavy duty rewriting that's going to happen to
> their code.
>

Can you elaborate on this please? I've only seen a few invariants
mentioned when reading the Stream Fusion paper and the stream-fusion
source code. They are:
1. 'Skip' values should have no semantic significance.
2. Don't construct bottom Streams. However, this seems to only apply
when the fusion rewrite rule is applied, which is not the case I am
talking about.

Cheers,
Reiner


More information about the Haskell-Cafe mailing list