Re: [Haskell-cafe] FiniteMap-like module for unordered keys?

2004-11-10 Thread R. Turk
On Tue, Nov 09, 2004 at 11:41:49PM +, Jorge Adriano Aires wrote: Hello, A hash-table becomes rather useless without mutable state AFAICS. Without it, one might almost just as well use a list of pairs... Could you please elaborate? Is there motive why an Hash Table, implemented as

[Haskell-cafe] Predicates in HaXml

2004-11-10 Thread Tom Spencer
Hi there, In XSLT there is an XPath function that will let you select a particular node in the current context, for example; xsl:value-of select=team[1] / in Michael Kay's article http://www-106.ibm.com/developerworks/xml/library/x-xslt/?article=xr This selects the first team element in the

RE: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-10 Thread Simon Marlow
On 09 November 2004 11:54, Graham Klyne wrote: I've not been following the Global variables debate too closely, it seeming to have something of a religious wars flavour, but I noticed that an example being proposed was how to achieve a one shot execution. Here's something I did when working

Re: [Haskell-cafe] Predicates in HaXml

2004-11-10 Thread Malcolm Wallace
Tom Spencer [EMAIL PROTECTED] writes: In XSLT there is an XPath function that will let you select a particular node in the current context, for example; xsl:value-of select=team[1] / This selects the first team element in the current context. Is there a work around to get similar

Re: [Haskell-cafe] Space efficiency problem

2004-11-10 Thread Keith Wansbrough
Hi, This may be silly, but I tried to code a simmulated annealing method to solve the travelling salesman prblem, by adapting the algorithm described in Numerical Recipes in C. Doesn't seem silly so far! :-) The problem is that there are so many iterations, that the program gets killed

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-10 Thread Keean Schupke
I have written a small library for supporting one-shot without using unsfePerformIO... The library uses SYSV semaphores under linux to make sure the functional argument of once is only ever run once. It uses the ProcessID as the key for the semaphore, so will even enforce the once-only property

Re: [Haskell-cafe] Space efficiency problem

2004-11-10 Thread Glynn Clements
Keith Wansbrough wrote: The problem is that there are so many iterations, that the program gets killed (kill -9) by the system. I'm not sure what you mean here - I've never encountered a system that kills processes with -9, other than at shutdown time. Are you sure it's -9? If a

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-10 Thread Judah Jacobson
What about the following? It does use unsafePerformIO, but only to wrap newMVar in this specific case. once :: Typeable a = IO a - IO a once m = let {-# NOINLINE r #-} r = unsafePerformIO (newMVar Nothing) in do y - takeMVar r x - case y of

Re: [Haskell-cafe] IO and State

2004-11-10 Thread Iavor S. Diatchki
Hello, Concurrency in Haskell (technically GHC) is much like concurrency in other languages, in that you fork off threads and do stuff with them, etc. I think you are perhaps thinking of another kind of concurrency, where different redexes in a term are evaluted simultaneously? Here is an

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-10 Thread Adrian Hey
OK, I'll play again.. On Wednesday 10 Nov 2004 4:39 pm, Judah Jacobson wrote: What about the following? It does use unsafePerformIO, but only to wrap newMVar in this specific case. once :: Typeable a = IO a - IO a once m = let {-# NOINLINE r #-} r = unsafePerformIO (newMVar

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-10 Thread Keean Schupke
Adrian Hey wrote: Suppose I had.. myOtherRef :: IO (IORef Char) myOtherRef = once (newIORef 'a') There's nothing to stop the compiler doing CSE and producing, in effect.. commonRef :: IO (IORef Char) commonRef = once (newIORef 'a') .. followed by substitution of all occurrences of myRef and

[Haskell-cafe] ANNOUNCE: Haskell Communities Activities Report (7th ed., November 2004)

2004-11-10 Thread Andres Loeh
Right in time, I am pleased to announce -- on behalf of the many contributers -- that the Haskell Communities and Activities Report (7th edition, November 2004) http://www.haskell.org/communities/ is now available from the Haskell

Re: [Haskell-cafe] FiniteMap-like module for unordered keys?

2004-11-10 Thread Remi Turk
Ugh, replying to myself... Obviously, the following contains a few mistakes...: On Wed, Nov 10, 2004 at 11:34:32AM +0100, R. Turk wrote: {-# OPTIONS -fglasgow-exts #-} {- I want a Hashable instance for String ;) -} import Data.FiniteMap import Data.HashTable (hashInt, hashString) import

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-10 Thread Keean Schupke
Hi, Here's another completely safe (and simpler way) to limit a computation to only happen once: once' :: IO () - IO () once' f = do k - getProcessID a - getEnv (showString MyApp.Main $ show k) case a of Just _ - return () _ - do f

Re: [Haskell-cafe] FiniteMap-like module for unordered keys?

2004-11-10 Thread John Meacham
On Tue, Nov 09, 2004 at 11:41:49PM +, Jorge Adriano Aires wrote: Hello, A hash-table becomes rather useless without mutable state AFAICS. Without it, one might almost just as well use a list of pairs... Could you please elaborate? Is there motive why an Hash Table, implemented as