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. Graph algorithms (.)
2. Memory usage patterns for server-like processes (Sean Charles)
3. Re: Graph algorithms (David Place)
4. merge two handles (Manfred Lotz)
5. Re: merge two handles (Antoine Latter)
6. Re: Does Haskell have a function that creates a list
corresponding to the nodes in a tree, from the leaf node to the
root node? (Stephen Tetley)
7. Re: merge two handles (Manfred Lotz)
8. Re: merge two handles (Antoine Latter)
9. Re: [Vendettaproject] (Fernando Henrique Sanches)
10. Re: merge two handles (David McBride)
----------------------------------------------------------------------
Message: 1
Date: Mon, 13 Jun 2011 14:38:03 +0200
From: "." <[email protected]>
Subject: [Haskell-beginners] Graph algorithms
To: [email protected]
Message-ID: <1307968683.3004.9.camel@eddy>
Content-Type: text/plain; charset="UTF-8"
Hello Haskellers,
I would like to implement a graph based algorithm, the sum-product
algorithm, in Haskell. I have looked at the FGL package, but I am not
sure whether this is really what I need.
For example, I need to know whether I am at a leaf (assuming the first
version I implement is the "original" algorithm which works for trees).
I would also need to store numerical values as well as functions
at nodes and edges. The FGL provides for "labels" at nodes and edges,
but these appear to have to be instances of classes such as Eq or Ord,
which does not work well for functions.
I could of course store node values and edge functions externally, e.g.
in a Map.
All this seems a bit awkward, but I may still just not have enough
experience in Haskell.
Can anyone give me a hint, or is there maybe even already a factor graph
implementation out there which I have missed?
Thanks,
Christian
------------------------------
Message: 2
Date: Mon, 13 Jun 2011 14:42:35 +0100
From: Sean Charles <[email protected]>
Subject: [Haskell-beginners] Memory usage patterns for server-like
processes
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Does anybody know of any reading material that I can ingest that will
give me a good feel for how Haskell memory allocation may (or may not)
spike at run-time.
I want to write a server process (yes, another web server) as part of my
continued learning and I just wondered how lazy evaluation might affect
a long running server process under a heavy "slashdot" type of load.
I know there are lazy and strict alternatives to a lot of functions, I
understand 9at least in principle) that you can use strict forms in
Data.Map et al. to ensure that the contents aren't thunked, and I know
that you can use $! to enforce a return result to be evaluated rather
than thunked but are there still issues to be wary of or am I needlessly
scaring myself?
Has anybody got any long-term use cases with Yesod, HappStack, Snapp and
such like.
It would be interesting to know!
:)
Thanks,
Sean Charles.
------------------------------
Message: 3
Date: Mon, 13 Jun 2011 10:24:31 -0400
From: David Place <[email protected]>
Subject: Re: [Haskell-beginners] Graph algorithms
To: "." <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Jun 13, 2011, at 8:38 AM, . wrote:
> I could of course store node values and edge functions externally, e.g.
> in a Map.
> All this seems a bit awkward, but I may still just not have enough
> experience in Haskell.
In my experience using fgl, I used maps to store values externally as you have
described. It didn't seem inconvenient at all.
------------------------------
Message: 4
Date: Mon, 13 Jun 2011 19:35:42 +0200
From: Manfred Lotz <[email protected]>
Subject: [Haskell-beginners] merge two handles
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Hi all,
I have two handles where I get stdout resp. stderr from a command
output.
Is it possible to merge those two handles so that I get a new input
handle in a way that data can be read from the new handle whenever it
is available from either of the two original handles?
--
Manfred
------------------------------
Message: 5
Date: Mon, 13 Jun 2011 12:51:02 -0500
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] merge two handles
To: Manfred Lotz <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On Mon, Jun 13, 2011 at 12:35 PM, Manfred Lotz <[email protected]> wrote:
> Hi all,
> I have two handles where I get stdout resp. stderr from a command
> output.
>
>
> Is it possible to merge those two handles so that I get a new input
> handle in a way that data can be read from the new handle whenever it
> is available from either of the two original handles?
>
>
Does what you're doing strictly need to be a handle?
One thing you could try is is using an IO Channel:
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html
You can create the channel, then fork off two threads to pump messages
from the handles into the channel, and then read the channel from your
main thread.
If it does need to be a Handle object, there is probably some GHC
black-magic you can do, but I recommend against it if at all possible.
You can ask for more details if you want.
If you're using unix, there might be something you can do with the
underlying unix file descriptors, but I don't know much about that.
Antoine
>
> --
> Manfred
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 6
Date: Mon, 13 Jun 2011 19:06:29 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Does Haskell have a function that
creates a list corresponding to the nodes in a tree, from the leaf
node to the root node?
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 13 June 2011 00:50, Thomas Davie <[email protected]> wrote:
> The problem with knot tying exercises is that as soon as you try to update
> you're in trouble.
Sounds like a job for zippers then....
I think Gerard Huet's original paper is online, which is the clearest
explanation (though the code is ML). There are Haskell focused
explanations on haskell.org / haskell-wiki.
------------------------------
Message: 7
Date: Mon, 13 Jun 2011 20:14:55 +0200
From: Manfred Lotz <[email protected]>
Subject: Re: [Haskell-beginners] merge two handles
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
On Mon, 13 Jun 2011 12:51:02 -0500
Antoine Latter <[email protected]> wrote:
> On Mon, Jun 13, 2011 at 12:35 PM, Manfred Lotz
> <[email protected]> wrote:
> > Hi all,
> > I have two handles where I get stdout resp. stderr from a command
> > output.
> >
> >
> > Is it possible to merge those two handles so that I get a new input
> > handle in a way that data can be read from the new handle whenever
> > it is available from either of the two original handles?
> >
> >
>
> Does what you're doing strictly need to be a handle?
>
> One thing you could try is is using an IO Channel:
> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html
>
Hmm, not quite sure. I was asking about handles because I use:
(_ ,Just hout ,Just herr ,p) <- createProcess (proc cmd parms) {
std_out = CreatePipe,
std_err = CreatePipe
}
which gives me handles to deal with.
--
Manfred
------------------------------
Message: 8
Date: Mon, 13 Jun 2011 15:14:26 -0500
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] merge two handles
To: Manfred Lotz <[email protected]>
Cc: Beginners Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On Mon, Jun 13, 2011 at 1:14 PM, Manfred Lotz <[email protected]> wrote:
> On Mon, 13 Jun 2011 12:51:02 -0500
> Antoine Latter <[email protected]> wrote:
>
>> On Mon, Jun 13, 2011 at 12:35 PM, Manfred Lotz
>> <[email protected]> wrote:
>> > Hi all,
>> > I have two handles where I get stdout resp. stderr from a command
>> > output.
>> >
>> >
>> > Is it possible to merge those two handles so that I get a new input
>> > handle in a way that data can be read from the new handle whenever
>> > it is available from either of the two original handles?
>> >
>> >
>>
>> Does what you're doing strictly need to be a handle?
>>
>> One thing you could try is is using an IO Channel:
>> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html
>>
>
> Hmm, not quite sure. I was asking about handles because I use:
>
> (_ ,Just hout ,Just herr ,p) <- createProcess (proc cmd parms) {
> ? ?std_out = CreatePipe,
> ? ?std_err = CreatePipe
> ?}
>
>
> which gives me handles to deal with.
>
You could create the pipe yourself, and then call 'createProcess' with
'UseHandle' instead, passing the same handle to both std_out and
std_error.
On a unix-y system you can do this with the functions in System.Posix.IO.
I'm not sure what you would do on windows. This might be a good
question to open up to a wider audience on the haskell-cafe mailing
list.
Antoine
------------------------------
Message: 9
Date: Mon, 13 Jun 2011 17:49:14 -0300
From: Fernando Henrique Sanches <[email protected]>
Subject: Re: [Haskell-beginners] [Vendettaproject]
To: [email protected],
[email protected],
[email protected], [email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I'm sorry, somehow my e-mail account got kidnapped. The link is a virus and
should NOT be opened. I apologise for any inconvenience.
Pe?o desculpas, de alguma forma minha conta de e-mail foi invadida. O link ?
um v?rus e N?O deve ser aberto. Pe?o desculpas por qualquer transtorno.
Fernando Henrique Sanches
Em 13 de junho de 2011 04:32, Fernando Henrique Sanches <
[email protected]> escreveu:
>
>
> --
> Voc? est? recebendo esta mensagem porque se inscreveu no grupo "Vendetta
> Project" dos Grupos do Google.
> Para postar neste grupo, envie um e-mail para
> [email protected].
> Para cancelar a inscri??o nesse grupo, envie um e-mail para
> [email protected].
> Para obter mais op??es, visite esse grupo em
> http://groups.google.com/group/fire-kitsune-anime-et-al-club?hl=pt-BR.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110613/8b0530ef/attachment-0001.htm>
------------------------------
Message: 10
Date: Mon, 13 Jun 2011 16:59:11 -0400
From: David McBride <[email protected]>
Subject: Re: [Haskell-beginners] merge two handles
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
The IO Channel antoine recommended is a very elegant solution to this.
main = do
let cmd = ..., parms =...
(_ ,Just hout ,Just herr ,p) <- createProcess (proc cmd parms)
chan <- newTChanIO :: IO (TChan String)
makeThread hout chan
makeThread herr chan
forever $ atomically $ readTchan chan >>= print
makeThread handle chan = forkIO $ forever $ do
hGetLine handle >>= atomically (writeTchan chan)
I haven't run this code, but this is the general idea that I've used
many times. The threads run taking input from their sources and
shoving it down the channel. The main thread continually reads
messages from the channel and blocks while it waits for new messages
to arrive.
On Mon, Jun 13, 2011 at 2:14 PM, Manfred Lotz <[email protected]> wrote:
> On Mon, 13 Jun 2011 12:51:02 -0500
> Antoine Latter <[email protected]> wrote:
>
>> On Mon, Jun 13, 2011 at 12:35 PM, Manfred Lotz
>> <[email protected]> wrote:
>> > Hi all,
>> > I have two handles where I get stdout resp. stderr from a command
>> > output.
>> >
>> >
>> > Is it possible to merge those two handles so that I get a new input
>> > handle in a way that data can be read from the new handle whenever
>> > it is available from either of the two original handles?
>> >
>> >
>>
>> Does what you're doing strictly need to be a handle?
>>
>> One thing you could try is is using an IO Channel:
>> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html
>>
>
> Hmm, not quite sure. I was asking about handles because I use:
>
> (_ ,Just hout ,Just herr ,p) <- createProcess (proc cmd parms) {
> ? ?std_out = CreatePipe,
> ? ?std_err = CreatePipe
> ?}
>
>
> which gives me handles to deal with.
>
>
> --
> Manfred
>
>
>
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 36, Issue 31
*****************************************