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?

Submitted by ajk on Fri, 05/27/2005 - 10:47am.

hWaitForInput in the IO module is the answer.

Submitted by jgoerzen on Fri, 05/27/2005 - 12:10pm.

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.

Submitted by ajk on Fri, 05/27/2005 - 2:11pm.

Heh. I've been doing too much socket programming lately, don't remember about terminal problems:)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.