
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

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@haskell.org http://www.haskell.org/mailman/listinfo/beginners

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@haskell.org http://www.haskell.org/mailman/listinfo/beginners

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@haskell.org http://www.haskell.org/mailman/listinfo/beginners
Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Hmm, I can't find anything like this. Do you have any other ideas? 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@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Oct 14, 2009, at 19:14 , Michael Mossey wrote:
Hmm, I can't find anything like this. Do you have any other ideas?
It's actually in Control.Concurrent. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Look here: http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.ht... Here is a sample function that delays for 3 seconds and then dies: main :: IO () main = do threadDelay 30000 return () -deech On Wed, Oct 14, 2009 at 6:16 PM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote:
On Oct 14, 2009, at 19:14 , Michael Mossey wrote:
Hmm, I can't find anything like this. Do you have any other ideas?
It's actually in Control.Concurrent.
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Thu, Oct 15, 2009 at 12:20 AM, aditya siram
Look here: http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.ht...
Here is a sample function that delays for 3 seconds and then dies: main :: IO () main = do threadDelay 30000 return ()
Sorry, but I can't help myself... the above is equivalent to main :: IO () main = threadDelay 3000 /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

Hi,
I was looking at something similar recently and I found the examples
in the hmidi package to be useful for this.
cabal install hmidi
and the examples are in
~/.cabal/packages/hackage.haskell.org/hmidi/0.1/hmidi-0.1.tar.gz (on
Mac OS X)
On Thu, Oct 15, 2009 at 8:49 AM, Magnus Therning
On Thu, Oct 15, 2009 at 12:20 AM, aditya siram
wrote: Look here: http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.ht...
Here is a sample function that delays for 3 seconds and then dies: main :: IO () main = do threadDelay 30000 return ()
Sorry, but I can't help myself... the above is equivalent to
main :: IO () main = threadDelay 3000
/M
-- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

That's very helpful info. I'm glad hmidi comes with an example. I can't find one for PortMidi, but maybe I'll figure out some basics with hmidi. Lorcan McDonald wrote:
Hi,
I was looking at something similar recently and I found the examples in the hmidi package to be useful for this.
cabal install hmidi and the examples are in ~/.cabal/packages/hackage.haskell.org/hmidi/0.1/hmidi-0.1.tar.gz (on Mac OS X)
participants (6)
-
aditya siram
-
Brandon S. Allbery KF8NH
-
Joe Fredette
-
Lorcan McDonald
-
Magnus Therning
-
Michael Mossey