[Haskell-cafe] Number of outstanding messages in Chan or TChan

2005-12-06 Thread Joel Reymont
Is there a way to check the number of outstanding messages in a Chan or TChan? I suspect my problem is related to not reading messages fast enough and I'd like to troubleshoot this by scanning my channels once every few seconds and dumping statistics. Thanks, Joel --

[Haskell-cafe] STM and `orElse` on a few thousand TMVars

2005-12-06 Thread Joel Reymont
Is it efficient to wait on a few thousand TMVars? How would I write something like that, assuming that my TMVars were in a list. Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

RE: [Haskell-cafe] Re: :t main

2005-12-06 Thread Simon Peyton-Jones
I've not been following this thread, but I wanted to check: you do know about Tarmo Uustalu's stuff about comonads, don't you? http://www.cs.helsinki.fi/u/ekarttun/comonad/ summarises (link to The essence of dataflow programming at the bottom) Simon | -Original Message- | From: [EMAIL

[Haskell-cafe] What's a thread doing / Erlang-style processes / Message passing

2005-12-06 Thread Joel Reymont
I'm finding myself in dire need of monitoring the Haskell runtime. More precisely, I would like to know what each that I launch is doing at a given point in time. Is there a way to obtain this information now? I would be fine with knowing if a thread is blocking on a foreign call, MVar or

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-12-06 Thread Benjamin Franksen
On Sunday 27 November 2005 11:28, [EMAIL PROTECTED] wrote: Andrew Pimlott: //about my highly spiritual essay on lazy computing of PI//: In addition to being clever and terribly funny, the conclusion foreshadows (inspired?) later work on Enron [1]. Come on, it is improbable that Master

[Haskell-cafe] Connecting to a running process (REPL)

2005-12-06 Thread Joel Reymont
Is there a good standard way of supplying a read-eval prompt in a program? I would like to a running process with something ghci-like to be able to inspect the state and possibly modify it. The running process would be heavily multi-threaded. Thanks, Joel --

[Haskell-cafe] Retrieving the caught signal within a handler

2005-12-06 Thread Joel Reymont
Is there a way to retrieve the signal within the signal handler? I would like to know the signal that I caught. Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Signal 2 and -threaded

2005-12-06 Thread Joel Reymont
I'm seeing some funky behavior in my program compiled with -threaded. It runs for a little while and then catches signal 2 and quits. This does not happen when -threaded is not used. I'm compiling my library with -threaded so that is always constant. The above applies to my main module and

[Haskell-cafe] TChan implementation: Why TVarList

2005-12-06 Thread Joel Reymont
Simon, Why did you guys implement TChan on top of your own TVarList instead of a regular list? -- | 'TChan' is an abstract type representing an unbounded FIFO channel. data TChan a = TChan (TVar (TVarList a)) (TVar (TVarList a)) type TVarList a = TVar (TList a) data TList a = TNil | TCons a

[Haskell-cafe] RE: TChan implementation: Why TVarList

2005-12-06 Thread Simon Peyton-Jones
The mutable cell is in the tail. A [TVar a] would be quite different. You can read about a very similar impl (based on MVars) in the original Concurrent Haskell paper (on my papers page) S | -Original Message- | From: Joel Reymont [mailto:[EMAIL PROTECTED] | Sent: 06 December 2005 11:28

[Haskell-cafe] Re: TChan implementation: Why TVarList

2005-12-06 Thread Joel Reymont
Well, I meant more like TVar [a] but I see that you are pulling from the front and appending to the rear. I need to implement a mailbox where messages can be pulled out based on a predicate or in order of arrival. I'm thinking of using a Map keyed on ClockTime. Do you have any

RE: [Haskell-cafe] Re: TChan implementation: Why TVarList

2005-12-06 Thread Simon Peyton-Jones
sounds as if you need a priority queue, so you can say give me the message with the earliest time but otherwise yes. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joel | Reymont | Sent: 06 December 2005 11:46 | To: Simon Peyton-Jones | Cc:

Re: [Haskell-cafe] Re: TChan implementation: Why TVarList

2005-12-06 Thread Joel Reymont
I think I could fake it on top of Data.Map keyed on ClockTime. findMax :: Map k a - (k, a) O(log n). The maximal key of the map. This would give me the maximum key which I can then proceed to remove. On Dec 6, 2005, at 12:35 PM, Simon Peyton-Jones wrote: sounds as if you need a priority

RE: [Haskell-cafe] STM and `orElse` on a few thousand TMVars

2005-12-06 Thread Simon Marlow
On 06 December 2005 10:02, Joel Reymont wrote: Is it efficient to wait on a few thousand TMVars? That depends... while waiting your thread consumes no CPU at all (of course), and simply waiting on all those TVars only imposes a small constant overhead on anyone updating one of the TVars (a

RE: [Haskell-cafe] Signal 2 and -threaded

2005-12-06 Thread Simon Marlow
On 06 December 2005 10:59, Joel Reymont wrote: I'm seeing some funky behavior in my program compiled with -threaded. It runs for a little while and then catches signal 2 and quits. This does not happen when -threaded is not used. I'm compiling my library with -threaded so that is always

RE: [Haskell-cafe] What's a thread doing / Erlang-style processes /Message passing

2005-12-06 Thread Simon Marlow
On 06 December 2005 10:28, Joel Reymont wrote: I'm finding myself in dire need of monitoring the Haskell runtime. More precisely, I would like to know what each that I launch is doing at a given point in time. Is there a way to obtain this information now? I would be fine with knowing if a

Re: [Haskell-cafe] STM and `orElse` on a few thousand TMVars

2005-12-06 Thread Joel Reymont
I'm trying to implement a better waitForChildren from the docs for Control.Concurrent. I would like to know when all the children exit, basically, and I thought it would be neat to try to do that with STM. Is there an advantage to STM here? Thanks, Joel On Dec 6, 2005, at 1:29

Re: [Haskell-cafe] Learning Haskell

2005-12-06 Thread Mark T.B. Carroll
Jimmie Houchin [EMAIL PROTECTED] writes: (snip) I have been perusing the haskell.org site and reading some of the tutorials. I just didn't want to expend lots of time just to find out that my math skills were woefully inadequate. I am grateful to learn (snip) Right. My math background isn't

Re: [Haskell-cafe] Number of outstanding messages in Chan or TChan

2005-12-06 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 06, 2005, 12:54:57 PM, you wrote: JR Is there a way to check the number of outstanding messages in a Chan JR or TChan? either 1) use MVars/TMVars instead of Channels. in any case your logging thread must consume data not slower than other channels produce then.

Re: [Haskell-cafe] What's a thread doing / Erlang-style processes / Message passing

2005-12-06 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 06, 2005, 1:27:58 PM, you wrote: JR #1 reading messages from a socket and posting to #3, JR #2 reading messages sent by #3 and writing to the socket, JR #3 reading messages sent by #1, processing them and posting to #2. what you get by dividing this into 3 threads?

Re[2]: [Haskell-cafe] Learning Haskell

2005-12-06 Thread Bulat Ziganshin
Hello Jimmie, Tuesday, December 06, 2005, 9:14:37 AM, you wrote: JH I would like to thank all who have replied to my inquiry. my two cents :) i'm not mathematician, but instead a professional programmer. i found that Haskell allow to write shorter, concise and robust programs. as Wirth says,

Re: [Haskell-cafe] STM and `orElse` on a few thousand TMVars

2005-12-06 Thread Joel Reymont
Well, I do need to have access to all those thread handles. On Dec 6, 2005, at 2:43 PM, Maarten Hazewinkel wrote: I apologise if this doesn't make sense (I'm fairly new to Haskell), but wouldn't a single shared counter be sufficient for this? Increment for each child launched. Decrement by

Re: [Haskell-cafe] Number of outstanding messages in Chan or TChan

2005-12-06 Thread Joel Reymont
I must eat crow :-(. Moving the thread and logger mailboxes from TChan to TMVar reduced memory consumption by an order of magnitude. I found my space leak. Moving serialization from [Word8] to unboxed arrays did not hurt either. On Dec 6, 2005, at 1:47 PM, Bulat Ziganshin wrote: either

Re: [Haskell-cafe] Re: TChan implementation: Why TVarList

2005-12-06 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 06, 2005, 2:46:24 PM, you wrote: JR I need to implement a mailbox where messages can be pulled out based JR on a predicate or in order of arrival. I'm thinking of using a Map JR keyed on ClockTime. JR Do you have any suggestions? it depends. what is the usage

Re: [Haskell-cafe] Connecting to a running process (REPL)

2005-12-06 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 06, 2005, 1:35:50 PM, you wrote: JR Is there a good standard way of supplying a read-eval prompt in a JR program? just fork a thread to do it :) -- Best regards, Bulatmailto:[EMAIL PROTECTED]

Re[2]: [Haskell-cafe] What's a thread doing / Erlang-style processes / Message passing

2005-12-06 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 06, 2005, 5:12:55 PM, you wrote: using Dynamic have meaning only if you don't know at compile time what messsages can be sent. is that really the case? JR That is correct. I deliver a scripting library and users can create JR messages of their own. creators of

Re: [Haskell-cafe] Retrieving the caught signal within a handler

2005-12-06 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 06, 2005, 1:39:10 PM, you wrote: JR Is there a way to retrieve the signal within the signal handler? JR I would like to know the signal that I caught. just pass signal number to the handler you installs :) installHandler sigPIPE Ignore Nothing

[Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-06 Thread haskell-cafe . mail . zooloo
Hi all, being occupied with learning both languages, I'm getting curious if Haskell couldn't achieve most of the performance gains resulting from uniqueness typing in Clean by *automatically* determining the reference count of arguments wherever possible and subsequently allowing them to be

Re: [Haskell-cafe] Learning Haskell

2005-12-06 Thread Donn Cave
Quoth Lemmih [EMAIL PROTECTED]: ... | You might wanna have a look at Don's FastPackedString library: | http://www.cse.unsw.edu.au/~dons/fps.html Thanks, that's actually what got me thinking about trying this again. | | I am also hoping to use it for web development. | | Wonder how `links' is

Re: [Haskell-cafe] Retrieving the caught signal within a handler

2005-12-06 Thread Joel Reymont
Thanks Bulat! This is what I ended up doing before you posted. Sometimes just the mere fact of asking makes you come up with a solution. I use #haskell for that alot :-). On Dec 6, 2005, at 4:17 PM, Bulat Ziganshin wrote: Hello Joel, Tuesday, December 06, 2005, 1:39:10 PM, you wrote: JR

[Haskell-cafe] Optimistic Evaluation was Re: Can't Haskell catch up with Clean's uniqueness typing?

2005-12-06 Thread Shae Matijs Erisson
[EMAIL PROTECTED] writes: being occupied with learning both languages, I'm getting curious if Haskell couldn't achieve most of the performance gains resulting from uniqueness typing in Clean by *automatically* determining the reference count of arguments wherever possible and subsequently

Re: Re[2]: [Haskell-cafe] What's a thread doing / Erlang-style processes / Message passing

2005-12-06 Thread Joel Reymont
Assuming I typed events like that I think I would need a typed sink for them as well. I only have one sink for the events and that is my message queue. I expect users to want User X, User Y, User Z within the same module and that's why I used Dynamic. On Dec 6, 2005, at 4:07 PM, Bulat

Re[2]: [Haskell-cafe] Number of outstanding messages in Chan or TChan

2005-12-06 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 06, 2005, 6:42:32 PM, you wrote: JR On Dec 6, 2005, at 1:47 PM, Bulat Ziganshin wrote: either 1) use MVars/TMVars instead of Channels. in any case your logging thread must consume data not slower than other channels produce then. in fact, using Chan have meaning

Re: [Haskell-cafe] Learning Haskell

2005-12-06 Thread Wolfgang Jeltsch
Am Dienstag, 6. Dezember 2005 14:43 schrieb Bulat Ziganshin: [...] so, in my feel, Haskell is better in areas where there is no standard quick-and-dirty solutions and all languages are in equal conditions, but it can't compete with Visual Basic in user interfaces, Erlang in distributed

Re: [Haskell-cafe] STM and `orElse` on a few thousand TMVars

2005-12-06 Thread Tomasz Zielonka
On Tue, Dec 06, 2005 at 02:52:03PM +, Joel Reymont wrote: Well, I do need to have access to all those thread handles. A TVar Int and a set/list of handles? Best regards Tomasz -- I am searching for a programmer who is good at least in some of [Haskell, ML, C++, Linux, FreeBSD, math] for

Re: [Haskell-cafe] Connecting to a running process (REPL)

2005-12-06 Thread Tomasz Zielonka
On Tue, Dec 06, 2005 at 10:35:50AM +, Joel Reymont wrote: Is there a good standard way of supplying a read-eval prompt in a program? I would like to a running process with something ghci-like to be able to inspect the state and possibly modify it. The running process would be

Re: [Haskell-cafe] Learning Haskell

2005-12-06 Thread Tomasz Zielonka
On Mon, Dec 05, 2005 at 09:08:32PM -0500, Cale Gibbard wrote: To your second question, I'd say that Haskell isn't bad at small things. One can write a great deal of useful one-or-two-line Haskell programs. I'd consider its use in shell-scripting like tasks perhaps a little bit odd, but not

Re: [Haskell-cafe] Can't Haskell catch up with Clean's uniqueness typing?

2005-12-06 Thread Tomasz Zielonka
On Tue, Dec 06, 2005 at 03:17:21PM +0100, [EMAIL PROTECTED] wrote: being occupied with learning both languages, I'm getting curious if Haskell couldn't achieve most of the performance gains resulting from uniqueness typing in Clean by *automatically* determining the reference count of

Re: [Haskell-cafe] Can't Haskell catch upwith Clean's uniqueness typing?

2005-12-06 Thread haskell-cafe . mail . zooloo
From: Shae Matijs Erisson - [EMAIL PROTECTED] Sent: Tuesday, December 06, 2005 6:16 PM [EMAIL PROTECTED] writes: being occupied with learning both languages, I'm getting curious if Haskell couldn't achieve most of the performance gains resulting from uniqueness typing in Clean by

Re: [Haskell-cafe] Can't Haskell catch upwith Clean's uniqueness typing?

2005-12-06 Thread Robert Dockins
On Tuesday 06 December 2005 04:00 pm, [EMAIL PROTECTED] wrote: From: Shae Matijs Erisson - [EMAIL PROTECTED] Sent: Tuesday, December 06, 2005 6:16 PM [EMAIL PROTECTED] writes: being occupied with learning both languages, I'm getting curious if Haskell couldn't achieve most of the

Re: [Haskell-cafe] Can't Haskell catch upwith Clean's uniqueness typing?

2005-12-06 Thread Robin Green
On Tuesday 06 December 2005 21:00, [EMAIL PROTECTED] wrote: In Clean, you can (and often are required to) assign uniqueness attributes to some parts of a function's type signature. The extended type checker ensures that none of those parts is referred to more than once during a single run of

Re: [Haskell-cafe] Connecting to a running process (REPL)

2005-12-06 Thread John Meacham
On Tue, Dec 06, 2005 at 10:35:50AM +, Joel Reymont wrote: Is there a good standard way of supplying a read-eval prompt in a program? You might want to look at this module which is a program independent read-eval prompt that I use for jhci. it is completely independent of the rest of the

[Haskell-cafe] New runtime crash, not sure what to make of it

2005-12-06 Thread Joel Reymont
Program compiled with -threaded on Mac OSX. Crash happens when waiting in select, I think. Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x [Switching to process 832 thread 0x2303] 0x0011ce20 in stg_enter_info () (gdb)

Re: [Haskell-cafe] STM and `orElse` on a few thousand TMVars

2005-12-06 Thread Einar Karttunen
On 06.12 20:57, Tomasz Zielonka wrote: On Tue, Dec 06, 2005 at 02:52:03PM +, Joel Reymont wrote: Well, I do need to have access to all those thread handles. Since thread creation is inside IO anyways you might want to look at Control.Concurrent.QSem which solves this in an easy fashion. If

[Haskell-cafe] FFI in threaded mode (was Re: New runtime crash, not sure what to make of it)

2005-12-06 Thread Joel Reymont
The program runs fine in non-threaded mode, including from within ghci. The crash below hapens when using -threaded. I tried to come up with a repro case but could not reproduce the crash. Thanks, Joel On Dec 7, 2005, at 12:51 AM, Joel Reymont wrote: Program compiled with -threaded

RE: [Haskell-cafe] Re: :t main

2005-12-06 Thread David Menendez
I wrote: | My guess is that comonadic IO would look more like dataflow | programming. Simon Peyton-Jones writes: I've not been following this thread, but I wanted to check: you do know about Tarmo Uustalu's stuff about comonads, don't you? http://www.cs.helsinki.fi/u/ekarttun/comonad/