[Haskell-cafe] Re: Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-14 Thread oleg
Stefan Monnier wrote: > I expected at first you were doing some funky type class molestation > so you can use "djinn" in your code and let Haskell fill it in. That has already been done: De-typechecker: converting from a type to a term http://www.haskell.org/pipermail/haskell/2005-March/015423.h

Re: [Haskell-cafe] Substring replacements

2005-12-14 Thread Branimir Maksimovic
From: [EMAIL PROTECTED] To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Thu, 15 Dec 2005 00:25:19 -0500 G'day all. Quoting Branimir Maksimovic <[EMAIL PROTECTED]>: > After seeing that your program is fastest (I've also tried one from > http://haskell.or

Re: [Haskell-cafe] Re: Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-14 Thread Donald Bruce Stewart
Or some TH... $(djinn [t| a -> a |]) or something like it. lennart: > I've certainly thought of providing the functionality > you want, but I've not done that yet. > Internally djinn uses some kind of ASTs, it might be possible > to use GADTs to do what you want in a type safe way. If

Re: [Haskell-cafe] Re: Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-14 Thread Lennart Augustsson
I've certainly thought of providing the functionality you want, but I've not done that yet. Internally djinn uses some kind of ASTs, it might be possible to use GADTs to do what you want in a type safe way. If not it should be possible to use Dynamic. -- Lennart Stefan Monnier wrote:

Re: [Haskell-cafe] Re: Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-14 Thread Tomasz Zielonka
On Thu, Dec 15, 2005 at 01:47:55AM -0500, Stefan Monnier wrote: > > I've written a small program that takes a (Haskell) type > > and gives you back a function of that type if one exists. > > It's kind of fun, so I thought I'd share it. > > Doh! It seems your code takes a string representing the t

[Haskell-cafe] Re: Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-14 Thread Stefan Monnier
> I've written a small program that takes a (Haskell) type > and gives you back a function of that type if one exists. > It's kind of fun, so I thought I'd share it. Doh! It seems your code takes a string representing the type and returns a string representing the code, whereas I expected at firs

Re: [Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-14 Thread Bulat Ziganshin
Hello Joel, Wednesday, December 14, 2005, 7:55:36 PM, you wrote: JR> With a 1 minute keep-alive timeout system is starting to get stressed JR> almost right away. There's verbose logging going on and almost every JR> event/packet sent and received is traced. The extra logging of the JR> timeou

Re: [Haskell-cafe] Substring replacements

2005-12-14 Thread ajb
G'day all. Quoting Branimir Maksimovic <[EMAIL PROTECTED]>: > After seeing that your program is fastest (I've also tried one from > http://haskell.org/hawiki/RunTimeCompilation but perhaps I'm not > that good in converting to search replace?) You probably did it right, but you could post your ve

Re: [Haskell-cafe] Substring replacements

2005-12-14 Thread Branimir Maksimovic
From: "Branimir Maksimovic" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] CC: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Thu, 15 Dec 2005 00:55:02 + From: Daniel Fischer <[EMAIL PROTECTED]> To: "Branimir Maksimovic" <[EMAIL PROTECTED]> CC: Haskell-Ca

Re: [Haskell-cafe] Substring replacements

2005-12-14 Thread Branimir Maksimovic
From: Daniel Fischer <[EMAIL PROTECTED]> To: "Branimir Maksimovic" <[EMAIL PROTECTED]> CC: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Wed, 14 Dec 2005 20:40:06 +0100 Hi Bane, nice algorithm. Since comparing chars _is_ cheap, it is to be expected that al

Re: [Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-14 Thread Einar Karttunen
On 14.12 23:07, Joel Reymont wrote: > Something like this? Comments are welcome! > timeout :: Int > timeout = 500 -- 1 second Is that correct? > {-# NOINLINE timers #-} > timers :: MVar Timers > timers = unsafePerformIO $ newMVar M.empty > > --- Call this first > initTimers :: IO () > initT

Re: [Haskell-cafe] Substring replacements

2005-12-14 Thread Branimir Maksimovic
From: Daniel Fischer <[EMAIL PROTECTED]> To: "Branimir Maksimovic" <[EMAIL PROTECTED]> CC: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Wed, 14 Dec 2005 17:10:20 +0100 > I think that's because on your machine Bulat's version have better > perfromance >

Re: [Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-14 Thread Joel Reymont
On Dec 14, 2005, at 7:48 PM, Tomasz Zielonka wrote: You don't have to check "every few seconds". You can determine exactly how much you have to sleep - just check the timeout/event with the lowest ClockTime. Something like this? Comments are welcome! It would be cool to not have to export an

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Joel Reymont
On Wed, Dec 14, 2005 at 02:17:17PM -, Simon Marlow wrote: Suppose you create two top-level IORefs with the same type, like this: var1 = unsafePerformIO $ newIORef 0 var2 = unsafePerformIO $ newIORef 0 GHC's CSE optimisation will common these up - after all, it's the same expressi

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 02:17:17PM -, Simon Marlow wrote: > Suppose you create two top-level IORefs with the same type, like this: > > var1 = unsafePerformIO $ newIORef 0 > var2 = unsafePerformIO $ newIORef 0 > > GHC's CSE optimisation will common these up - after all, it's the same > exp

Re: [Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-14 Thread Joel Reymont
On Dec 14, 2005, at 7:48 PM, Tomasz Zielonka wrote: You don't have to check "every few seconds". You can determine exactly how much you have to sleep - just check the timeout/event with the lowest ClockTime. Right, thanks for the tip! I would need to way a predefined amount of time when the

Re: [Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 07:11:15PM +, Joel Reymont wrote: > I figure I can have a single timer thread and a timer map keyed on > ClockTime. I would try to get the min. key from the map every few > seconds, compare it to clock time, fire of the event as needed, > remove the timer and repea

Re: [Haskell-cafe] Substring replacements

2005-12-14 Thread Daniel Fischer
Hi Bane, nice algorithm. Since comparing chars _is_ cheap, it is to be expected that all the hash-rotating is far more costly for short search patterns. The longer the pattern, the better this gets, I think -- though nowhere near KMP (or would it?). However, I don't see how to (efficiently) do

Re: [Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-14 Thread Joel Reymont
On Dec 14, 2005, at 6:06 PM, Bulat Ziganshin wrote: as i already said, you can write to socket directly in your worker thread True. 1 less thread to deal with... multiplied by 4,000. you can use just one timeouts thread for all your bots. if this timeout is constant across program run, then

Re: [Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-14 Thread Bulat Ziganshin
Hello Joel, Wednesday, December 14, 2005, 7:55:36 PM, you wrote: JR> In my current architecture I launch a two threads per socket where JR> the socket reader places results in a TMVar and the socket writer JR> takes input from a TChan. as i already said, you can write to socket directly in you

Re[2]: [Haskell-cafe] Unbound threads and FFI

2005-12-14 Thread Bulat Ziganshin
Hello Simon, Wednesday, December 14, 2005, 7:39:43 PM, you wrote: SM> Do other Haskell threads get blocked during an FFI call? SM> | safeunsafe SM> --+ SM> -threaded| NO YES SM> no -threaded | YES YES there is also `threadsafe` specif

[Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-14 Thread Joel Reymont
Folks, In my current architecture I launch a two threads per socket where the socket reader places results in a TMVar and the socket writer takes input from a TChan. I also have the worker thread the does the bulk of packet processing and a timer thread. The time thread sleeps for a few m

RE: [Haskell-cafe] Unbound threads and FFI

2005-12-14 Thread Simon Marlow
On 14 December 2005 15:34, Joel Reymont wrote: > On Dec 14, 2005, at 3:21 PM, Simon Marlow wrote: > >> this only happens in the -threaded RTS, in the non-threaded RTS a FFI >> call will block all the other Haskell threads. > > Just to be absolutely sure... Does the above apply to safe _and_ > un

RE: [Haskell-cafe] killThread and FFI calls

2005-12-14 Thread Simon Marlow
On 14 December 2005 15:35, Joel Reymont wrote: > On Dec 14, 2005, at 3:22 PM, Simon Marlow wrote: > >> On 14 December 2005 14:26, Joel Reymont wrote: >> >>> How does killThread work with FFI calls? What happens at the low >>> level when a thread is blocked on an FFI call and received a >>> KillT

Re: [Haskell-cafe] Substring replacements

2005-12-14 Thread Daniel Fischer
Hi, Bane and all, Am Dienstag, 13. Dezember 2005 14:22 schrieben Sie: > > > In real world situation your KMP will always be fastest on average. > > > I like that we are not using C arrays as then we have advantage > > > of lazyness and save on memory usage. C++ program will be faster > > > on shor

Re: [Haskell-cafe] killThread and FFI calls

2005-12-14 Thread Joel Reymont
On Dec 14, 2005, at 3:22 PM, Simon Marlow wrote: On 14 December 2005 14:26, Joel Reymont wrote: How does killThread work with FFI calls? What happens at the low level when a thread is blocked on an FFI call and received a KillThread exception? Does it exit immediately via some GHC magic or is

Re: [Haskell-cafe] Unbound threads and FFI

2005-12-14 Thread Joel Reymont
On Dec 14, 2005, at 3:21 PM, Simon Marlow wrote: this only happens in the -threaded RTS, in the non-threaded RTS a FFI call will block all the other Haskell threads. Just to be absolutely sure... Does the above apply to safe _and_ unsafe FFI? I have been using the non-threaded runtime wit

RE: [Haskell-cafe] killThread and FFI calls

2005-12-14 Thread Simon Marlow
On 14 December 2005 14:26, Joel Reymont wrote: > How does killThread work with FFI calls? What happens at the low > level when a thread is blocked on an FFI call and received a > KillThread exception? Does it exit immediately via some GHC magic or > is the exception caught when the FFI call return

RE: [Haskell-cafe] Unbound threads and FFI

2005-12-14 Thread Simon Marlow
On 14 December 2005 14:37, Joel Reymont wrote: > How do unbound threads play with FFI? According to Simon PJ, each > foreign call will get its own OS thread if its blocked. > > How does GHC determine if the call is blocked? Does each call get its > own OS thread from the start? Sometime later? W

[Haskell-cafe] Re: GHC internal error: traverse_weak_ptr_list: not WEAK

2005-12-14 Thread Joel Reymont
Forgot to mention that I was profiling at the time. ghc -O --make -threaded -prof -auto-all loadtest.hs -o loadtest -lssl -lcrypto -lz ./loadtest +RTS -hc -sloadtest.gc Cannot compile without -O because of the "extent too large" assembler error. On Dec 14, 2005, at 2:40 PM, Joel Reymont

[Haskell-cafe] GHC internal error: traverse_weak_ptr_list: not WEAK

2005-12-14 Thread Joel Reymont
loadtest: internal error: traverse_weak_ptr_list: not WEAK Please report this as a bug to glasgow-haskell-bugs@haskell.org, or http://www.sourceforge.net/projects/ghc/ Has anyone seen this before? I got this after running a 1,300 socket connections for a while (probably x3 threads overa

[Haskell-cafe] Unbound threads and FFI

2005-12-14 Thread Joel Reymont
How do unbound threads play with FFI? According to Simon PJ, each foreign call will get its own OS thread if its blocked. How does GHC determine if the call is blocked? Does each call get its own OS thread from the start? Sometime later? Does this depend on the safe/unsafe specs of the fore

[Haskell-cafe] killThread and FFI calls

2005-12-14 Thread Joel Reymont
Folks, How does killThread work with FFI calls? What happens at the low level when a thread is blocked on an FFI call and received a KillThread exception? Does it exit immediately via some GHC magic or is the exception caught when the FFI call returns? Thanks, Joel -- http://wage

RE: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Simon Marlow
On 14 December 2005 10:11, Joel Reymont wrote: > I'm a bit lost in the discussion. Why do I need -fno-cse and how do I > seq at the top-level? > > On Dec 14, 2005, at 10:05 AM, Tomasz Zielonka wrote: > >> On Wed, Dec 14, 2005 at 10:03:42AM -, Simon Marlow wrote: >>> Well sure, but it's only

[Haskell-cafe] Re: [Haskell] Re: Announcing Djinn, new version 2004-12-13

2005-12-14 Thread Lennart Augustsson
Well, the proof search is terminating (and complete) so it has to stop somewhere. That happens to be result with this particular search strategy. -- Lennart Chung-chieh Shan wrote: Lennart Augustsson <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in gmane.comp.lang.haskell.g

RE: [Haskell-cafe] Re: Bringing Erlang to Haskell

2005-12-14 Thread Simon Peyton-Jones
There's a (GHC-specific) Wiki page on concurrent programming in GHC, in the new GHC Wiki. http://hackage.haskell.org/trac/ghc/wiki/GhcConcurrency Feel free to add more info to it. I've dropped in the links below. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EM

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Joel Reymont
I'm a bit lost in the discussion. Why do I need -fno-cse and how do I seq at the top-level? On Dec 14, 2005, at 10:05 AM, Tomasz Zielonka wrote: On Wed, Dec 14, 2005 at 10:03:42AM -, Simon Marlow wrote: Well sure, but it's only a temporary problem. And you also have to tell them to us

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 10:03:42AM -, Simon Marlow wrote: > Well sure, but it's only a temporary problem. And you also have to tell > them to use {-# NOINLINE #-} and -fno-cse :-) -fno-cse is also neccesary? Oops, I didn't know that. Can I simply place it in {-# OPTIONS -fno-cse #-} ? Best r

RE: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Simon Marlow
On 14 December 2005 09:57, Tomasz Zielonka wrote: > On Wed, Dec 14, 2005 at 09:51:16AM -, Simon Marlow wrote: >>> Here is an example how you can initialize a top-level STM variable. >>> http://www.uncurry.com/repos/TimeVar/TimeVar.hs >>> It just forks a new thread inside unsafePerformIO, i

[Haskell-cafe] Re: Announcing Djinn, new version 2004-12-13

2005-12-14 Thread Chung-chieh Shan
Lennart Augustsson <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in gmane.comp.lang.haskell.general: > There is a new version of Djinn available, with two notable > new features: Haskell data types can be defined and the > found functions are sorted (heuristically) to present the > best

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 09:51:16AM -, Simon Marlow wrote: > > Here is an example how you can initialize a top-level STM variable. > > http://www.uncurry.com/repos/TimeVar/TimeVar.hs > > It just forks a new thread inside unsafePerformIO, it runs > > "atomically" in it and passes the result t

RE: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Simon Marlow
On 13 December 2005 18:34, Tomasz Zielonka wrote: > On Tue, Dec 13, 2005 at 06:08:23PM +, Joel Reymont wrote: >> Can this be done now or is this a GHC 6.5 feature? >> >> My combination of unsafePerformIO with atomically $ newTVar does not >> seem to be working. > > Here is an example how you

[Haskell-cafe] RE: [Haskell] TArray?

2005-12-14 Thread Simon Marlow
On 13 December 2005 14:52, Jan-Willem Maessen wrote: > On Dec 13, 2005, at 8:46 AM, Simon Marlow wrote: >> [In response to another plea for TArrays] > >> In the past I have used arrays of TVars, as Thomasz suggested. It >> would indeed be better to have a primitive STM array, the only >> problem

Re: [Haskell-cafe] Substring replacements

2005-12-14 Thread Branimir Maksimovic
From: Daniel Fischer <[EMAIL PROTECTED]> To: "Branimir Maksimovic" <[EMAIL PROTECTED]> CC: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Tue, 13 Dec 2005 11:23:29 +0100 After seeing that your program is fastest (I've also tried one from http://haskell.org

RE: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Simon Peyton-Jones
newTVarIO in the HEAD, and therefore it's in any nightly-build snapshot, which you can freely download. The next major release will be 6.6, but it's a few months off. Meanwhile I hope you can use the workaround that Tomasz posted. Simon | -Original Message- | From: [EMAIL PROTECTED] [mai