[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
| To: Simon Peyton-Jones
| Cc: Haskell Cafe
| Subject: TChan implementation: Why TVarList
| 
| 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 (TVarList a)
| 
|   Thanks, Joel
| 
| --
| http://wagerlabs.com/
| 
| 
| 
| 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[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 suggestions?

Thanks, Joel

On Dec 6, 2005, at 11:31 AM, Simon Peyton-Jones wrote:


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)


--
http://wagerlabs.com/





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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: Haskell Cafe
| Subject: [Haskell-cafe] Re: TChan implementation: Why TVarList
| 
| 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 suggestions?
| 
|   Thanks, Joel
| 
| On Dec 6, 2005, at 11:31 AM, Simon Peyton-Jones wrote:
| 
|  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)
| 
| --
| http://wagerlabs.com/
| 
| 
| 
| 
| 
| ___
| Haskell-Cafe mailing list
| Haskell-Cafe@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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 queue, so you can say give me the
message with the earliest time but otherwise yes.



--
http://wagerlabs.com/





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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 scenario?



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe