Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: "sleep" in Haskell (Michael Mossey)
2. Re: "sleep" in Haskell (Brandon S. Allbery KF8NH)
3. Re: "sleep" in Haskell (aditya siram)
4. Re: "sleep" in Haskell (Magnus Therning)
5. Re: "sleep" in Haskell (Lorcan McDonald)
6. Re: "sleep" in Haskell (Michael Mossey)
7. sorting by elements in a tuple (Ryan Temple)
8. Re: sorting by elements in a tuple (Daniel Fischer)
9. Re: sorting by elements in a tuple (Chadda? Fouch?)
----------------------------------------------------------------------
Message: 1
Date: Wed, 14 Oct 2009 16:14:45 -0700
From: Michael Mossey <[email protected]>
Subject: Re: [Haskell-beginners] "sleep" in Haskell
To: Joe Fredette <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
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
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 2
Date: Wed, 14 Oct 2009 19:16:39 -0400
From: "Brandon S. Allbery KF8NH" <[email protected]>
Subject: Re: [Haskell-beginners] "sleep" in Haskell
To: Michael Mossey <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
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] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university KF8NH
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url :
http://www.haskell.org/pipermail/beginners/attachments/20091014/e8c4363f/PGP-0001.bin
------------------------------
Message: 3
Date: Wed, 14 Oct 2009 18:20:42 -0500
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] "sleep" in Haskell
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Look here:
http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html#v:threadDelay
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 <
[email protected]> 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] [email protected]
> system administrator [openafs,heimdal,too many hats] [email protected]
> electrical and computer engineering, carnegie mellon university KF8NH
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091014/4568ad4c/attachment-0001.html
------------------------------
Message: 4
Date: Thu, 15 Oct 2009 08:49:27 +0100
From: Magnus Therning <[email protected]>
Subject: Re: [Haskell-beginners] "sleep" in Haskell
To: aditya siram <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Thu, Oct 15, 2009 at 12:20 AM, aditya siram <[email protected]> wrote:
> Look here:
> http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html#v:threadDelay
>
> 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
------------------------------
Message: 5
Date: Thu, 15 Oct 2009 09:03:31 +0100
From: Lorcan McDonald <[email protected]>
Subject: Re: [Haskell-beginners] "sleep" in Haskell
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
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 <[email protected]> wrote:
> On Thu, Oct 15, 2009 at 12:20 AM, aditya siram <[email protected]> wrote:
>> Look here:
>> http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html#v:threadDelay
>>
>> 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
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 6
Date: Thu, 15 Oct 2009 01:30:10 -0700
From: Michael Mossey <[email protected]>
Subject: Re: [Haskell-beginners] "sleep" in Haskell
To: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
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)
>
------------------------------
Message: 7
Date: Fri, 16 Oct 2009 00:19:34 +0100
From: Ryan Temple <[email protected]>
Subject: [Haskell-beginners] sorting by elements in a tuple
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I am wanting to sort a list of tuples by the first and then the second item
in the tuple. So [(1,2),(4,2),(2,5)] would become [(1,2),(2,5),(4,2)] I am
attempting to use the Sorty function but don't seem to be having much luck
tuplesort :: [(a,b)] -> [(a,b)]
tuplesort [(_,_)] = sortBy (comparing fst) -- this is an attempt to
organise by the first element in the tuple
Any help would be much appreciated
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091015/1ed3244e/attachment-0001.html
------------------------------
Message: 8
Date: Fri, 16 Oct 2009 08:07:11 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] sorting by elements in a tuple
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-15"
Am Freitag 16 Oktober 2009 01:19:34 schrieb Ryan Temple:
> I am wanting to sort a list of tuples by the first and then the second item
> in the tuple. So [(1,2),(4,2),(2,5)] would become [(1,2),(2,5),(4,2)]
That's what "sort" already does:
sort [(1,2),(4,2),(2,5),(4,1)] gives [(1,2),(2,5),(4,1),(4,2)]
> I am attempting to use the Sorty function but don't seem to be having much
> luck
>
> tuplesort :: [(a,b)] -> [(a,b)]
> tuplesort [(_,_)]
That defines tuplesort on lists containing exactly one pair, probably not what
you want.
> = sortBy (comparing fst)
This doesn't conform to the type you gave. "sortBy (comparing fst)" has type
Ord a => [(a,b)] -> [(a,b)]
So your definition of tuplesort has type
Ord a => [(c,d)] -> [(a,b)] -> [(a,b)]
which doesn't look like the type of a sorting function.
> -- this is an attempt to
> organise by the first element in the tuple
You would achieve that by
tuplesort = sortBy (comparing fst)
or, eta-expanded,
tuplesort xs = sortBy (comparing fst) xs
But if you finally want to sort by the second component also (subordinate to
sorting by
the first component), it's much easier to go the whole way at once and use
plain "sort".
>
> Any help would be much appreciated
------------------------------
Message: 9
Date: Fri, 16 Oct 2009 10:37:38 +0200
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] sorting by elements in a tuple
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Fri, Oct 16, 2009 at 8:07 AM, Daniel Fischer
<[email protected]> wrote:
> You would achieve that by
>
> tuplesort = sortBy (comparing fst)
>
> or, eta-expanded,
>
> tuplesort xs = sortBy (comparing fst) xs
>
> But if you finally want to sort by the second component also (subordinate to
> sorting by
> the first component), it's much easier to go the whole way at once and use
> plain "sort".
>
For completeness sake, you can do it like that :
tuplesort = sortBy (comparing fst `mplus` comparing snd)
It's interesting to know how to do it if you want to sort using a
different function than the compare of Ord. The "mplus" use some
instances of Monoid that you'll find in Data.Monoid so don't forget to
import it.
--
Jedaï
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 16, Issue 8
****************************************