"zipping" two streams in the IO monad

How could I "zip" two possibily infinite streams obtained by IO operations, for example to return the infinite list of pairs of values read both from channel a and from channel b with getChanContents? In general, how does one implement a function like "getChanContents" wich returns an infinite list? Tell me just some pointer to information of course, I don't want an entire functional programming lesson :) Vincenzo

On Thu, 19 Sep 2002 22:06:59 +0200
Nick Name
In general, how does one implement a function like "getChanContents" wich returns an infinite list? Tell me just some pointer to information of course, I don't want an entire functional programming lesson :)
See unsafeInterleaveIO: http://www.haskell.org/ghc/docs/latest/html/base/System.IO.Unsafe.html#unsaf... This is how getContents is implemented so that it reads the file lazily. It is "unsafe" in that it doesn't guarantee any particuar order of evaluation with respect to other IO operations. Duncan
participants (2)
-
Duncan Coutts
-
Nick Name