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:  Network.Curl POST body not showing up (Erik de Castro Lopo)
   2. Re:  Closing a channel (Ertugrul Soeylemez)
   3. Re:  Closing a channel (Christopher Done)


----------------------------------------------------------------------

Message: 1
Date: Fri, 13 May 2011 17:32:44 +1000
From: Erik de Castro Lopo <[email protected]>
Subject: Re: [Haskell-beginners] Network.Curl POST body not showing up
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Michael Xavier wrote:

> I have an active issue with the author of the project on github discussing
> this very thing:
> 
> https://github.com/snoyberg/http-enumerator/issues/14#comment_1086615
> 
> I'm not really up to implementing auth quite yet but it may help you in your
> endeavors. Definitely keep me posted if you decide to tackle this issue.

I did.

    
https://github.com/snoyberg/http-enumerator/commit/346c16607cad805e393e666e599dbc6c2a3d7efd

It should be in version 6.5 of httpenumerator which is already on
Hackage. Please test it and if it works for you close the github
issue.

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



------------------------------

Message: 2
Date: Fri, 13 May 2011 10:02:31 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] Closing a channel
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Lyndon Maydwell <[email protected]> wrote:

> I'm trying to implement a program that accumulates a list of items
> through many IO actions, then use these in another part of the program
> as a list.
>
> I've found Control.Concurrent.Chan which seems to provide a nice
> abstraction with getChanContents :: Chan a -> IO [a], but there
> doesn't seem to be a way for the source to close the channel.

You don't close channels, but just read exactly as many items as you
write.


> Are channels the right abstraction for something like this? Should
> look in to (itter|enumer)at(or|ee)s instead... They seem to encompass
> this model, but look quite involved.

Iteratees are an abstraction /around/ a construct like Chan.  They allow
you to split the input processing (in this case from the channel) into
three separate problems:  Fetching, transforming and using the data.  In
particular, they solve the problems of lazy IO.

To answer your question:  MVar, Chan and STM would all solve your
problem, but in different ways.  In general I try to avoid Chan, because
if your reading end is slower than your writing end, you may run into
resource problems.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/





------------------------------

Message: 3
Date: Fri, 13 May 2011 10:03:14 +0200
From: Christopher Done <[email protected]>
Subject: Re: [Haskell-beginners] Closing a channel
To: Lyndon Maydwell <[email protected]>
Cc: Biginners Haskell Mailinglist <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

On 12 May 2011 12:20, Lyndon Maydwell <[email protected]> wrote:

> Hi Beginners.
>
> I'm trying to implement a program that accumulates a list of items
> through many IO actions, then use these in another part of the program
> as a list.
>
> I've found Control.Concurrent.Chan which seems to provide a nice
> abstraction with getChanContents :: Chan a -> IO [a], but there
> doesn't seem to be a way for the source to close the channel.
>
> Are channels the right abstraction for something like this? Should
> look in to (itter|enumer)at(or|ee)s instead... They seem to encompass
> this model, but look quite involved.
>

For what it's worth you can implement this abstraction ontop of channels.

module Control.Concurrent.Chan.Closeable where

import           Control.Concurrent.Chan (Chan)
import qualified Control.Concurrent.Chan as C
import           Data.Maybe

getChanWhileJust :: Chan (Maybe a) -> IO [a]
getChanWhileJust ch = fmap (catMaybes . takeWhile isJust) (C.getChanContents
ch)

-- ?> chan <- newChan :: IO (Chan (Maybe Integer))
-- ?> writeList2Chan chan (map Just [1..10] ++ [Nothing])
-- ?> getChanWhileJust chan
-- [1,2,3,4,5,6,7,8,9,10]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110513/b4ac0f2d/attachment-0001.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 35, Issue 25
*****************************************

Reply via email to