timed execution in Haskell
Submitted by metaperl on Fri, 05/27/2005 - 9:03am.
A question on #C++ caught my eye:
im waiting for user input .. using getch() .. if a user hasnt entered another key within 1 second i want to perform some action, rather than waiting for a newline or something else .. using a while doesnt work because getch() hangs until u enter a char .. any ideas?
how easy would something like this be in Haskell?
- metaperl's blog
- Login to post comments
hWaitForInput in the IO module is the answer.
Partially, anyway. The terminal also needs to be set into, I believe, raw mode, which would also have to be done in C++. How to do that, in either language, I'm not certain.
Heh. I've been doing too much socket programming lately, don't remember about terminal problems:)