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: Parallel and Concurrent Programming in Haskell -
Rate-Limiting the Producer (Tim Perry)
2. Re: breaking code to several lines (Gesh hseG)
3. tree structure for resolving nested references (Renah Scarowsky)
----------------------------------------------------------------------
Message: 1
Date: Wed, 29 Jan 2014 10:38:25 -0800
From: Tim Perry <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Parallel and Concurrent Programming
in Haskell - Rate-Limiting the Producer
Message-ID:
<cafvgasuv3y01d53g86kmcxq_yc69qrmwknjozdpe9_txoao...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I suspect you need to post this somewhere besides Haskell-Beginners. Good
luck.
Tim
On Mon, Jan 27, 2014 at 6:31 AM, Kilian Gebhardt <
[email protected]> wrote:
> Hi,
> I'm working through Simon Marlows Parallel and Concurrent Programming in
> Haskell.
> In Chapter 4, p. 69, or
> http://chimera.labs.oreilly.com/books/1230000000929/ch04.html#_rate_limiting_the_producerthere
> is the task to extend a stream processing module based on
> Control.Monad.Par in such a way that the producer is rate-limited, i.e. the
> producer should not produce more than the consumer can consume.
>
> The book suggests the following type:
> data IList a
> = Nil
> | Cons a (IVar (IList a))
> | Fork (Par ()) (IList a)
>
> I struggle to construct the functions for this type, as I don't know what
> to do with the IList in the Fork case. It seems more natural to me, to have
> an IVar (IList a) instead, whose value is provided by the computation in
> Par () in the following way:
>
> Fork (Par ()) (IVar (IList a))
>
> streamFromListLimited :: NFData a => Int -> Int -> [a] -> Par (Stream a)
> streamFromListLimited f d xs = do
> var <- new
> fork $ loop f xs var
> return var
> where
> loop :: NFData a => Int -> [a] -> Stream a -> Par ()
> loop _ [] var = put var Nil
> loop 0 (x:xs) var = do
> tail <- new
> put var (Fork (loop d xs tail) tail)
> loop n (x:xs) var = do
> tail <- new
> put var (Cons x tail)
> loop (n-1) xs tail
>
> Can someone give me a hint?
> Thanks,
> Kilian
>
> _______________________________________________
> 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/20140129/f8ae18ae/attachment-0001.html>
------------------------------
Message: 2
Date: Wed, 29 Jan 2014 21:34:54 +0200
From: Gesh hseG <[email protected]>
To: [email protected], The Haskell-Beginners Mailing List -
Discussion of primarily beginner-level topics related to Haskell
<[email protected]>
Subject: Re: [Haskell-beginners] breaking code to several lines
Message-ID:
<CACS5XqMRuySO4tY5xxvCzjmTeK=whatmf8fllj_capoqgoq...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
>
> On Mon, Dec 23, 2013 at 4:42 PM, Miro Karpis
> <[email protected]>wrote:
>>
>>> Hi please,... I have one sql insert statement which is too long to be on
>>> one line. Is there a way that I can break it several lines? Or does it have
>>> to be everything in one line?
>>>
>>> here is the query:
>>> execute_ conn "INSERT INTO ttableXY
>>> (column1, column2, column3, column4, column5, column6, column7) VALUES
>>> ('var1', 'var2', 'var3', 'var4', 'var5', 'var6', 'var7')"
>>>
>>> Thanks,
>>> Miro
>>>
>> In addition, you could break the string into two strings and append them.
That is,
execute_conn $ "INSERT INTO ttableXY (column1, column2, column3, column4,
column5, column6, column7) " ++
"VALUES ('var1', 'var2', 'var3', 'var4', 'var5', 'var6', 'var7')"
HTH,
Gesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140129/10fcf302/attachment-0001.html>
------------------------------
Message: 3
Date: Thu, 30 Jan 2014 13:38:46 +0200
From: "Renah Scarowsky" <[email protected]>
To: <[email protected]>
Subject: [Haskell-beginners] tree structure for resolving nested
references
Message-ID: <00b101cf1daf$d6e5cb20$84b16160$@com>
Content-Type: text/plain; charset="us-ascii"
Hi,
I'm doing some xml processing where elements can reference each other in one
particular way.
Such a reference is resolved by copying the content of the referenced
element to the content of the referencing element.
For example, <A ref="B">foo</A>, <B>bar</B> would resolve to
<A>bar</A><B>bar</B>.
The references can also be nested, for example:
<A ref="B">foo</A>, <B ref="C">bar</B><C>baz</C> would resolve to
<A>baz</A><B>baz</B><C>baz</C>.
I'm looking to collect all the elements with such references in some sort of
(tree?) container for efficient resolution.
The container should serve two purposes:
1) I need to check whether there are any cyclic references (for
example, A references B which references C which references A) - which is
invalid.
2) I need to traverse the tree upwards in order to copy the content
from one element to another - beginning with the "leaves" (elements with
non-nested references), working up the "branches" (elements with nested
references) to the "roots" (elements with references that are not referenced
by other elements). Obviously there can be many roots, as well as many
leaves that are roots themselves.
I'm not familiar with trees in Haskell at all. Can anyone provide some
guidance on whether there are any existing containers that would be
appropriate for checking cyclic dependencies and for reverse traversal?
Thanks,
Renah Scarowsky
Suite Solutions
Create>Manage>Deploy
<http://www.suite-sol.com/> http://www.suite-sol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140130/e0a707df/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 67, Issue 27
*****************************************