Re: [Haskell-cafe] strange stack overflow with Data.Map

2005-12-28 Thread Udo Stenzel
David Roundy wrote: > > stats elems = foldl add_elem Map.empty elems > > add_elem m x = Map.insertWith (+) x 1 m > [...] > I tried defining > > add_elem m x = let m' = Map.insertWith (+) x 1 m >Just num = Map.lookup x m' >in seq num m' > to force the (+) to be e

[Haskell-cafe] strange stack overflow with Data.Map

2005-12-28 Thread David Roundy
Hi all, I've got a problem that I'm seeing using either Data.Map or Data.IntMap. > module Main where > import Data.List > import qualified Data.IntMap as Map > stats elems = foldl add_elem Map.empty elems > add_elem m x = Map.insertWith (+) x 1 m > main = print $ stats $ take 100 $ repeat 1

Re: [Haskell-cafe] NewBinary on Ptrs

2005-12-28 Thread Bulat Ziganshin
Hello Pupeno, Wednesday, December 28, 2005, 6:27:54 AM, you wrote: P> My question now is how to turn a Ptr into a BinHandle to use NewBinary on it, P> or is there another way to do it ? no. you need to write this self. see at implementation of readBinMem, it's closest code to what you need afai

Re[6]: [Haskell-cafe] binary IO

2005-12-28 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 27, 2005, 9:35:13 PM, you wrote: JR> Quite possibly. I'm looking for hard proven results at this point and JR> while you are making bold claims about the throughput of your JR> pickling library you are not willing to demonstrate this throughput JR> in a real-life

Re: [Haskell-cafe] Re: binary IO

2005-12-28 Thread Bulat Ziganshin
Hello Peter, Tuesday, December 27, 2005, 11:26:29 PM, you wrote: PS> My guess is that you would learn more if _you_ would plug PS> the different IO libraries into your test code. I'm certain Peter, because you claimed that Haskell can be made as effective as C, please help us :) your BlockIO li

Re: [Haskell-cafe] OpenAL bindings / compiling ghc 6.5

2005-12-28 Thread Michael Benfield
I tried to compile ghc 6.4.2 and I got the same thing (sits forever at that point). Sven Panne wrote: > Although I haven't tried it, you should be able to simply use the OpenAL and ALUT directories from the HEAD in the 6.4 branch. I don't know how to do this. The Cabal User's Guide says "Afte

Re: [Haskell-cafe] Help with "shootout"

2005-12-28 Thread Isaac Gouy
--- Chris Kuklewicz <[EMAIL PROTECTED]> wrote: -snip- > which is the wrong kind of CPU anyway -- they > test on an AMD system "What machine are you running the programs on?" http://shootout.alioth.debian.org/gp4/faq.php#machine __ Yahoo!

RE: [Haskell-cafe] Re: Haskell Speed

2005-12-28 Thread Branimir Maksimovic
From: Isaac Gouy <[EMAIL PROTECTED]> To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Re: Haskell Speed Date: Tue, 27 Dec 2005 20:12:01 -0800 (PST) Branimir Maksimovic wrote: > Of course, first example uses [String] instead of Data.HashTable > as other languages do. Imagine C program does

[Haskell-cafe] Help with "shootout"

2005-12-28 Thread Chris Kuklewicz
Hello all, I decided to put together an entry for one of the shooutout categories: http://haskell.org/hawiki/ChameneosEntry It involves 4 threads. There is no current Haskell entry. Anyone have comments? Alterations? I can't have created the best code yet. I don't have the compilers for the o

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Robert Dockins
On Dec 28, 2005, at 1:38 PM, Tomasz Zielonka wrote: On Wed, Dec 28, 2005 at 05:28:28PM +, Chris Kuklewicz wrote: But STM, wrapped in small pieces, makes for interesting IO commands (untested): waitForZero :: (Num a, Ord a) => (TVar a) -> IO () waitForZero tv = atomically $ do v <- rea

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Tomasz Zielonka
On Wed, Dec 28, 2005 at 05:28:28PM +, Chris Kuklewicz wrote: > But STM, wrapped in small pieces, makes for interesting IO commands > (untested): > waitForZero :: (Num a, Ord a) => (TVar a) -> IO () > waitForZero tv = atomically $ do > v <- readTVar tv > when (v>0) retry This function is r

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Chris Kuklewicz
>> >> STM or IO ? >> >> You need a count of shared locks "S", *Var Word32. >> >> To increase the count "S", you need to hold a mutex "E", *Var (). >> So (take mutex "E" >> increment "S" >> release "E") is the the combined >> operation. >> >> To decrease the count "S", you do not need to hold a mu

Re: [Haskell-cafe] OpenAL bindings / compiling ghc 6.5

2005-12-28 Thread Joel Reymont
Sven, The logs are at http://wagerlabs.com/logs.tgz. I have 6.4.1 installed from darwinports into /opt/local. Thanks, Joel On Dec 28, 2005, at 4:14 PM, Sven Panne wrote: Am Mittwoch, 28. Dezember 2005 16:24 schrieb Joel Reymont: I think you should post to cvs-ghc. I was able to ge

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Robert Dockins
On Dec 28, 2005, at 11:14 AM, Chris Kuklewicz wrote: John Goerzen wrote: Hello, I have the need for a locking object that can provide shared and exclusive locks in much the same manner as the POSIX flock() function. A thread that acquires an exclusive lock has a guarantee that no other

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Chris Kuklewicz
John Goerzen wrote: > Hello, > > I have the need for a locking object that can provide shared and > exclusive locks in much the same manner as the POSIX flock() function. > > A thread that acquires an exclusive lock has a guarantee that no other > thread holds any locks. > > A thread that acquir

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Chris Kuklewicz
Hi, "The little book of semaphones" (287 pages) is available at http://greenteapress.com/semaphores/ It has a slightly better solution that uses two mutexes and a count, see the Readers-writers problem, section 4.2 page 67 (pdf page 79). It also goes on to discuss fairness and starvation and wri

Re: [Haskell-cafe] OpenAL bindings / compiling ghc 6.5

2005-12-28 Thread Sven Panne
Am Mittwoch, 28. Dezember 2005 16:24 schrieb Joel Reymont: > I think you should post to cvs-ghc. I was able to get things to > compile (almost) on 10.4.3 but had to configure with --disable-alut -- > disable-openal, etc. Why were those --disable-foo options necessary? In theory everything should b

Re: [Haskell-cafe] OpenAL bindings / compiling ghc 6.5

2005-12-28 Thread Sven Panne
Am Mittwoch, 28. Dezember 2005 16:15 schrieb Michael Benfield: > I see here: > http://www.haskell.org/HOpenGL/newAPI/ > > OpenAL bindings listed as part of the Hierachical Libraries. And when I > download the source to a development snapshot of GHC, there they are. > Is there a way to install this

[Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread John Goerzen
Hello, I have the need for a locking object that can provide shared and exclusive locks in much the same manner as the POSIX flock() function. A thread that acquires an exclusive lock has a guarantee that no other thread holds any locks. A thread that acquires a shared lock has a guarantee that

Re: [Haskell-cafe] OpenAL bindings / compiling ghc 6.5

2005-12-28 Thread Joel Reymont
Mike, I think you should post to cvs-ghc. I was able to get things to compile (almost) on 10.4.3 but had to configure with --disable-alut -- disable-openal, etc. Joel On Dec 28, 2005, at 3:15 PM, Michael Benfield wrote: I see here: http://www.haskell.org/HOpenGL/newAPI/ OpenAL bi

[Haskell-cafe] OpenAL bindings / compiling ghc 6.5

2005-12-28 Thread Michael Benfield
I see here: http://www.haskell.org/HOpenGL/newAPI/ OpenAL bindings listed as part of the Hierachical Libraries. And when I download the source to a development snapshot of GHC, there they are. Is there a way to install this on GHC 6.4? Alternatively... I can't get GHC 6.5 to compile. I do ./c

Re: [Haskell-cafe] Re: binary IO

2005-12-28 Thread Joel Reymont
I would compare Haskell to visiting the chiropractor. You will walk straighter, stand taller and your life will never be the same :D. On Dec 28, 2005, at 1:56 AM, Peter Simons wrote: you'll find that knowing and understanding Haskell will change the way you design software -- regardless of th

Re: [Haskell-cafe] Re: binary IO

2005-12-28 Thread Joel Reymont
Amen! Haskell has forever realigned my mind-gears and I'm observing positive results as we speak :-). On Dec 28, 2005, at 1:56 AM, Peter Simons wrote: Even if you ultimately decide to write your application in another language, you'll find that knowing and understanding Haskell will change th

Erlang vs. Haskell (was Re: [Haskell-cafe] binary IO)

2005-12-28 Thread Joel Reymont
On Dec 28, 2005, at 1:05 PM, Sebastian Sylvan wrote: How does this work if you remove the file-reading? I mean just putting the file on a small TCP/IP file server with some simulated latency and bandwidth limitation, and then connecting to that in each thread? This is probably the way to go but

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Sebastian Sylvan
On 12/28/05, Joel Reymont <[EMAIL PROTECTED]> wrote: > > On Dec 28, 2005, at 11:40 AM, Lennart Augustsson wrote: > > > Why on earth do you want each tread to open the file and unpickle? > > Why not unpickle once and reuse it? > > Or, if this is just a test and in the future they will all read > > f

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Joel Reymont
On Dec 28, 2005, at 11:40 AM, Lennart Augustsson wrote: Why on earth do you want each tread to open the file and unpickle? Why not unpickle once and reuse it? Or, if this is just a test and in the future they will all read from different files (or sockets), then maybe you are hitting on a diffe

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Lennart Augustsson
Joel Reymont wrote: You are right in that I spent the first few weeks learning. By now I know that pickling is the bottleneck, though. The timeleak code is very simple. It forks X threads where each thread opens a file for reading. Why on earth do you want each tread to open the file and un

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Einar Karttunen
On 27.12 07:00, Tomasz Zielonka wrote: > Some time ago I was playing with DNS too. I have a library that can > construct and interpret DNS packets, but it's a bit incomplete right > now. It reads packets as Strings, but it should be quite straightforward > to make it read and interpret FastPackedSt

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Joel Reymont
On Dec 27, 2005, at 10:30 PM, Tomasz Zielonka wrote: Let's see if I understand correctly. There are 17605 messages in trace.dat. On my hardware the average message unpicking time is 0.0002s when you only have a single thread. So, it indeed seems that with 1000 threads it should be possible t

RE: [Haskell-cafe] Haskell vs. Erlang for heavy-duty network apps

2005-12-28 Thread Simon Peyton-Jones
I've already said to Joel (off-list) how valuable I think his experience of using Haskell for a new kind of real application is. I see no reason in principle why Haskell shouldn't work just fine for his kind of application. But he's pushing hard on parts of the system (both run-time-system and li