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: IO action on a list of [IO a] (Christopher Howard)
2. Re: IO action on a list of [IO a] (Brent Yorgey)
3. Re: IO action on a list of [IO a] (Michael Orlitzky)
----------------------------------------------------------------------
Message: 1
Date: Sun, 07 Oct 2012 08:41:32 -0800
From: Christopher Howard <[email protected]>
Subject: Re: [Haskell-beginners] IO action on a list of [IO a]
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
On 10/06/2012 06:16 AM, Manfred Lotz wrote:
> Hi all,
> I want to do an IO action on a list of [IO a] like this:
>
> myfor :: (a -> IO () ) -> [IO a] -> IO ()
> myfor _ [] = return ()
> myfor f (x:xs) = do
> x' <- x
> f x'
> myfor f xs
>
>
>
> Is there a library function doing just this?
>
>
>
For the curious newbies among us: Why would you want to perform an IO
action on a list of IO actions?
--
frigidcode.com
indicium.us
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20121007/332127c8/attachment-0001.pgp>
------------------------------
Message: 2
Date: Sun, 7 Oct 2012 13:27:30 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] IO action on a list of [IO a]
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sun, Oct 07, 2012 at 08:41:32AM -0800, Christopher Howard wrote:
> On 10/06/2012 06:16 AM, Manfred Lotz wrote:
> > Hi all,
> > I want to do an IO action on a list of [IO a] like this:
> >
> > myfor :: (a -> IO () ) -> [IO a] -> IO ()
> > myfor _ [] = return ()
> > myfor f (x:xs) = do
> > x' <- x
> > f x'
> > myfor f xs
> >
> >
> >
> > Is there a library function doing just this?
> >
> >
> >
>
> For the curious newbies among us: Why would you want to perform an IO
> action on a list of IO actions?
"Perform an IO action on a list of IO actions" is kind of a poor way
to phrase it, which makes it sound arcane. Here's a better way to say
what's going on: "take a list of IO actions, chain an additional
action onto the end of each, then run all the resulting actions in
sequence".
It's not really "performing an IO action on another" (which doesn't
even really make sense) but chaining IO actions together, using the
usual
(>>=) :: IO a -> (a -> IO b) -> IO b
-Brent
------------------------------
Message: 3
Date: Sun, 07 Oct 2012 14:05:23 -0400
From: Michael Orlitzky <[email protected]>
Subject: Re: [Haskell-beginners] IO action on a list of [IO a]
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 10/07/2012 12:41 PM, Christopher Howard wrote:
>
> For the curious newbies among us: Why would you want to perform an IO
> action on a list of IO actions?
Let's say you have a list of URLs, and you map,
downloadUrl :: URL -> IO Stuff
over that list. The result will be a list, [IO Stuff]. Now suppose you
want to print them all one at a time. Printing is an IO action, so this
is performing an IO action (print) on a list of IO "actions" (downloaded
URLs).
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 52, Issue 10
*****************************************