[Haskell-beginners] Lazy variant of sequence (or other way to approach problem)

Nathan Hüsken nathan.huesken at posteo.de
Wed Sep 26 17:41:57 CEST 2012


Hey,

In my (SDL based) haskell program, I do:

events <- liftM ( takeWhile (/= NoEvent)) $ sequence $ repeat pollEvent

The execution of this never returns, I am guessing that is because
sequence evaluation never stops.

But if sequence would be lazy (and assuming pollEvent returns NoEvent at
some point) this should stop, should it not?
Is there a lazy variant of sequence? Or am I missing something here
completely?

Thanks!
Nathan



More information about the Beginners mailing list