[Haskell-beginners] "sleep" in Haskell

Joe Fredette jfredett at gmail.com
Wed Oct 14 16:58:55 EDT 2009


Your program may not be multithreaded, but it is threaded. :)

so threadSleep <ms> will still work, it'll just pause the thread it's  
executed in, namely the main thread, which is the one you want. So I  
guess the answer to your first question is yes, it can be used. And 2,  
no you don't need to learn to use threads, beyond the very basic  
calling of threadSleep.

On Oct 14, 2009, at 4:54 PM, Michael Mossey wrote:

>
> Hi Joe,
>
> My program does not need to be threaded, so initially I ignored  
> System.Thread, but perhaps either
>
> (1) This particular function can be used in a single-thread process
>
> or
>
> (2) I need to learn how to use threads if I want to place IO  
> operations in time.
>
> ?
>
> Joe Fredette wrote:
>> As I recall, System.Thread (or something similar) provides  
>> "threadSleep". A quick hoogle ought to find it.
>> hoogle -> haskell.org/hoogle
>> On Oct 14, 2009, at 4:50 PM, Michael Mossey wrote:
>>> I can't find a "sleep" function in Haskell. This relates to my  
>>> wish to use PortMidi and control the timing of actions. Maybe  
>>> there is another way to do this sort of thing in Haskell. Can  
>>> anyone help, either with PortMidi or just a general explanation of  
>>> how IO operations could be placed at certain points in time?
>>>
>>> Thanks,
>>> Mike
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners at haskell.org
>>> http://www.haskell.org/mailman/listinfo/beginners
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



More information about the Beginners mailing list