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: version of base in Haskell Platform (Magnus Therning)
2. mapM etc. (Dennis Raddle)
3. Re: mapM etc. (Alexey G)
4. Problem with do statement (Michael Litchard)
5. Re: OpenGL keyboardMouseCallback ...confused over type
(Arlen Cuss)
6. Re: mapM etc. (Sean Perry)
7. Re: Problem with do statement (Chadda? Fouch?)
8. Re: mapM etc. (Chadda? Fouch?)
9. Re: mapM etc. (Chadda? Fouch?)
----------------------------------------------------------------------
Message: 1
Date: Fri, 1 Jul 2011 18:06:59 +0200
From: Magnus Therning <[email protected]>
Subject: Re: [Haskell-beginners] version of base in Haskell Platform
To: [email protected]
Message-ID: <20110701160659.GA19726@ohann>
Content-Type: text/plain; charset="us-ascii"
On Thu, Jun 30, 2011 at 10:49:23AM -0700, Dennis Raddle wrote:
> I just installed the latest Haskell Platform on Windows XP. Then I tried to
> install the musicxml package, and it says it needs base 3.something. How do
> I find out what version of base comes with a version of the Haskell
> Platform?
I guess you actually would like to know what versions of base you have
installed, so run:
% ghc-pkg list base
/M
--
Magnus Therning OpenPGP: 0xAB4DFBA4
email: [email protected] jabber: [email protected]
twitter: magthe http://therning.org/magnus
I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
-- Alan Kay
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110701/02d1da9f/attachment-0001.pgp>
------------------------------
Message: 2
Date: Fri, 1 Jul 2011 13:08:43 -0700
From: Dennis Raddle <[email protected]>
Subject: [Haskell-beginners] mapM etc.
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
It's been about a year since I used Haskell and I'm rusty. I think I knew
how to do this once, but I need a reminder.
I've got some functions:
getDeviceInfo :: Int -> IO DeviceInfo
name :: DeviceInfo -> String
I want to do something like
func :: IO ()
func = do
ds <- mapM getDeviceInfo [0..10]
mapM_ (print . name) ds
Is there a way to combine 'getDeviceInfo', 'name', and 'print' in one line?
Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110701/62dc31f7/attachment-0001.htm>
------------------------------
Message: 3
Date: Fri, 1 Jul 2011 23:48:24 +0300
From: Alexey G <[email protected]>
Subject: Re: [Haskell-beginners] mapM etc.
To: Dennis Raddle <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Try this:
> mapM (\x -> getDeviceInfo x >>= print . name) [0..10]
2011/7/1 Dennis Raddle <[email protected]>
> It's been about a year since I used Haskell and I'm rusty. I think I knew
> how to do this once, but I need a reminder.
>
> I've got some functions:
>
> getDeviceInfo :: Int -> IO DeviceInfo
>
> name :: DeviceInfo -> String
>
> I want to do something like
>
> func :: IO ()
> func = do
> ds <- mapM getDeviceInfo [0..10]
> mapM_ (print . name) ds
>
> Is there a way to combine 'getDeviceInfo', 'name', and 'print' in one line?
>
> Dennis
>
>
> _______________________________________________
> 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/20110701/c929a57d/attachment-0001.htm>
------------------------------
Message: 4
Date: Fri, 1 Jul 2011 16:47:03 -0700
From: Michael Litchard <[email protected]>
Subject: [Haskell-beginners] Problem with do statement
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
I received an error message that might be due to indentation,
and not what the error message claims.
Here's the error, then the code. Below that I have some comments.
ghc --make CreateSession.lhs
[2 of 3] Compiling HtmlParsing ( HtmlParsing.lhs, HtmlParsing.o )
HtmlParsing.lhs:81:5:
The last statement in a 'do' construct must be an expression:
let makeIDPage = do { initial }
> generateResourceHtml :: Curl -> String -> String -> FilePath -> IO (Either
> String String)
> generateResourceHtml curl user pass ipFile = do
> urlSequence <- popURLrec ipFile
> let makeIDPage = do
> initial = urlInitial urlSequence
> login = urlLogin urlSequence
> flash1 = urlFlash1 urlSequence
> flash2 = urlFlash2 urlSequence
> showWebForwards = urlShowWebForwards urlSequence
> quickCreate = urlQuickCreate urlSequence
> getResource = urlGetResource urlSequence
> curlResp curl $ initial method_GET
> curlResp curl $ urlLogin urlSequence $ loginOpts user pass
> curlResp curl $ urlFlash1 urlSequence resourceOpts
> curlResp curl $ urlFlash2 urlSequence resourceOpts
> curlResp curl $ urlShowWebForwards urlSequence resourceOpts
> curlResp curl $ urlQuickCreate urlSequence resourceOpts
> curlResp curl $ urlGetResource urlSequence resourceOpts
> runErrorT makeIDPage
It seems to me the first do construct ends with a statement,
runErrorT makeIDPage.
Also the second do construct ends with a statement as well,
> curlResp curl $ urlGetResource urlSequence resourceOpts
So I'm either wrong about what the definition of a statement is, or
this problem is really about indentation or similar.
Clarification?
------------------------------
Message: 5
Date: Sat, 02 Jul 2011 14:16:39 +1000
From: Arlen Cuss <[email protected]>
Subject: Re: [Haskell-beginners] OpenGL keyboardMouseCallback
...confused over type
To: Alexey G <[email protected]>
Cc: Sean Charles <[email protected]>, [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 01/07/11 19:58, Alexey G wrote:
> Hello. I didn't read the thread, but I think, that this code help you
> https://gist.github.com/1031576.
Thanks! This is a great reference.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJODpuiAAoJEDiWqExGnQ/QdAwQAJOl5d7jXIqDdwzkZDqvdFsw
7mri7D75ljHQHCbSA+uM+93lnw064eUPncrfWVjlLT0wiVq7UaFzBcOe5Rueg4RX
YPuKlOyBozyABz/ilXbtWYqOr+bDEOqzpEAZKzCTAOJ7d1QREa+kYcRwekIEQHJc
IVnaqlh+n1DUC65FH9WeB09G+pIrwV0NEg0+V92T73jfr3BZhH6isRLTCoEGMOXw
8d2b+efSjfiWProHtyYln9cm+wWwIp54LRzl9qI5AYf50bg3J2yXnXinOAGU3Xxw
Ob9VMJzrsD9KLLSuX5DXbaapRdbsRmAb/PKWaZCpxvWLqSy1b+Um48ioUqPRRdoL
4nxcCAX/Dnip4+BBdzpGDbvc3efIny/SAoTtuhLpN20LX5yzd27XbrZvcWcDP+Ul
jzOt7/EeGVvT3Fy7gU5ht5dtpmIF+baQ9m5k/hfsB1J5rGtq4TboEXHx5h8CHUzL
Qo32CpnGJjIBngmq95mAVvGjmj6hwtbMBQOujV85g85/rx/CdwPgHmUNoJuAVSsV
lftdCN/MuTDtroq0KwwDrfAu6N2GU8hZqA/nRbBSKV9ugoLmulfHgQlF0fmxQoTB
xWLYv6vJH5PQCKs8VDAIwTG+DbtBLjXdZSO+A2vtRYQrF87s4UyjyUbp/tkrwPOM
4ppkLXwJCLT7C7VWvpUK
=mLYx
-----END PGP SIGNATURE-----
------------------------------
Message: 6
Date: Fri, 1 Jul 2011 22:23:36 -0700
From: Sean Perry <[email protected]>
Subject: Re: [Haskell-beginners] mapM etc.
To: Dennis Raddle <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Jul 1, 2011, at 1:08 PM, Dennis Raddle wrote:
> It's been about a year since I used Haskell and I'm rusty. I think I knew how
> to do this once, but I need a reminder.
>
> I've got some functions:
>
> getDeviceInfo :: Int -> IO DeviceInfo
>
> name :: DeviceInfo -> String
>
> I want to do something like
>
> func :: IO ()
> func = do
> ds <- mapM getDeviceInfo [0..10]
> mapM_ (print . name) ds
>
> Is there a way to combine 'getDeviceInfo', 'name', and 'print' in one line?
>
I end up with either:
join . fmap (mapM_ (print . name)) $ mapM getDeviceInfo [1..10]
or
mapM getDeviceInfo [1..10] >>= mapM_ (print . name)
You can move the call to name into the mapM using (fmap name . getDeviceInfo)
but I left them separate to match your code better.
------------------------------
Message: 7
Date: Sat, 2 Jul 2011 09:50:12 +0200
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] Problem with do statement
To: Michael Litchard <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On Sat, Jul 2, 2011 at 1:47 AM, Michael Litchard <[email protected]> wrote:
> I received an error message that might be due to indentation,
> and not what the error message claims.
>
> Here's the error, then the code. Below that I have some comments.
>
> ghc --make CreateSession.lhs
> [2 of 3] Compiling HtmlParsing ? ? ?( HtmlParsing.lhs, HtmlParsing.o )
>
> HtmlParsing.lhs:81:5:
> ? ?The last statement in a 'do' construct must be an expression:
> ? ?let makeIDPage = do { initial }
>
>
>> generateResourceHtml :: Curl -> String -> String -> FilePath -> IO (Either
>> String String)
>> generateResourceHtml curl user pass ipFile = do
>> ? urlSequence <- popURLrec ipFile
>> ? let makeIDPage = do
>> ? ? ? initial = urlInitial urlSequence
>> ? ? ? login = urlLogin urlSequence
you can't write "initial = url..." directly in a do construct. You
have to introduce any definition with a let. Here Haskell read it
"makeIDPage = (do initial) = urlInitial urlSequence...'" which doesn't
make sense at all.
--
Jeda?
------------------------------
Message: 8
Date: Sat, 2 Jul 2011 09:55:50 +0200
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] mapM etc.
To: Alexey G <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On Fri, Jul 1, 2011 at 10:48 PM, Alexey G <[email protected]> wrote:
> Try this:
>
>> mapM (\x -> getDeviceInfo x >>= print . name) [0..10]
>
Though they're not very well known, Control.Monad now contains
"composition" monad operators, so you can just write :
> mapM_ (getDeviceInfo >=> print . name) [0..10]
which is pretty elegant (to my eyes at least).
(>=>) :: (a -> m b) -> (b -> m c) -> a -> m c
--
Jeda?
------------------------------
Message: 9
Date: Sat, 2 Jul 2011 10:00:00 +0200
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] mapM etc.
To: Alexey G <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On Sat, Jul 2, 2011 at 9:55 AM, Chadda? Fouch? <[email protected]> wrote:
> On Fri, Jul 1, 2011 at 10:48 PM, Alexey G <[email protected]> wrote:
>> Try this:
>>
>>> mapM (\x -> getDeviceInfo x >>= print . name) [0..10]
>>
>
>> mapM_ (getDeviceInfo >=> print . name) [0..10]
>
Or maybe, to be more consistent order-wise :
> mapM_ (print . name <=< getDeviceInfo) [0..10]
>
> (>=>) :: (a -> m b) -> (b -> m c) -> a -> m c
>
Oops, forgot the constraint :
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
--
Jeda?
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 37, Issue 3
****************************************