[Haskell-cafe] Progress indications
bit at mutantlemon.com
Thu Nov 29 13:16:12 EST 2007
Lazy evaluation can sometimes be helpful here. I once wrote a
raytracer that computed the resulting image using a pure function that
returned a list of the RGB colors of the pixels: [(Word8, Word8,
When plotting the pixels to the screen in the IO monad, the value of
each pixel would be computed on demand, and so the image was shown
progressively as the calculations were performed.
I was new to haskell when I made this program and when I ran the
program for this first time I was expecting to experience a long pause
and then a display of the final image. I was very surprised to see
On Nov 29, 2007 12:03 AM, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
> In a "normal" programming language, you might write something like this:
> for x = 1 to 1000000
> print x
> ...do slow complex stuff...
> next x
> In Haskell, you're more likely to write something like
> result k = filter my_weird_condition $ map strange_conversion $
> unfoldr ...
> That means that when you try to process the result, lots of processing
> happens, and your program just appears to lock up until a result is
> produced. So, like, how do you make it so that some kind of progress
> information is output while it's working? (Aside from dunking everything
> into the IO monad and ruining all your beautiful abstractions.) There
> doesn't seem to be a clean solution to this one...
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe