Hi Stephen,

On 2 January 2011 13:35, Stephen Tetley <stephen.tet...@gmail.com> wrote:
> Can a lazy cons be implemented for (infinite) Streams in the
> Stream-Fusion style?

I made a mailing list post about almost exactly this issue a while ago
(http://www.mail-archive.com/haskell-cafe@haskell.org/msg82981.html).
There was no really nice solution offered: I think the best you can do
is define your stream operations with a lazy pattern match using my
"eta" trick from that post:

  eta stream = Stream (case stream of Stream s _ -> unsafeCoerce s ::
()) (case stream of Stream _ step -> unsafeCoerce step)

Then instead of writing:

 f (Stream x y) = ...

Write:

  f (eta -> Stream x y) = ...

(This is necessary because lazy pattern matches on existential data
constructors using ~ cannot even be expressed in System FC, so it is
unclear how GHC could implement them).

Cheers,
Max

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to