[Haskell-cafe] Difficult memory leak in array processing

2006-11-23 Thread Niko Korhonen
Hi everyone, I have the following code whose purpose is to add dither (noise) to a given array. The code looks very straightforward but apparently it has a memory leak somewhere. Here I try to run the algorithm for an array of 10,000,000 integers. Ten million unboxed strict integers should equal

Re: [Haskell-cafe] Difficult memory leak in array processing

2006-11-23 Thread isto
Hi Niko, to, 2006-11-23 kello 12:11 +0200, Niko Korhonen kirjoitti: I've tried applying seq and some other strictness tricks (such as x == x) pretty much everywhere on the code with no results. Could you please help me understand what is going on here? Have I misunderstood something critical

[Haskell-cafe] SimonPJ and Tim Harris explain STM - video

2006-11-23 Thread Bayley, Alistair
http://channel9.msdn.com/Showpost.aspx?postid=231495 The links to the video are a couple of yellow buttons at the bottom of the article: Watch or Download. I haven't watched this yet (it's nearly an hour long, I think). Found via reddit (http://reddit.com). Haskeller's on TV (sort of...) woot

Re: [Haskell-cafe] Difficult memory leak in array processing

2006-11-23 Thread Udo Stenzel
Niko Korhonen wrote: I have the following code whose purpose is to add dither (noise) to a given array. The code looks very straightforward but apparently it has a memory leak somewhere. No, it doesn't. It can't, because it doesn't even compile. After correcting the obvious (lo,

[Haskell-cafe] Re: Difficult memory leak in array processing

2006-11-23 Thread apfelmus
Ah, yet another UndeadArray necromancer exhausting his stack of bones. May the forces of light suggest to structure the incantation of darkness? modifyArray arr i f = readArray arr i = \y - writeArray arr i (f y) accumM :: (MArray a e m, Ix i) = (e - e' - e) - a i e -

[Haskell-cafe] Re: Difficult memory leak in array processing

2006-11-23 Thread apfelmus
Udo Stenzel wrote: Niko Korhonen wrote: I have the following code whose purpose is to add dither (noise) to a given array. The code looks very straightforward but apparently it has a memory leak somewhere. No, it doesn't. It can't, because it doesn't even compile. After correcting the

Re: [Haskell-cafe] LLVM back end

2006-11-23 Thread Kenneth Hoste
On 20 Nov 2006, at 08:27, Michael T. Richter wrote: I've been eyeing LLVM[1] as interesting technology -- brief executive summary: a virtual machine suited as the back end of compiler output with optimised native code then coming from it as either JIT-based execution of the LLVM bytecode

[Haskell-cafe] Re: Type Error. Why!?

2006-11-23 Thread Joachim Durchholz
Neil Mitchell schrieb: How is this an FAQ: http://www.haskell.org/haskellwiki/Why_Haskell_just_works It's a nice piece of marketing, but I can't imagine anyone has ever asked Why Haskell just works, unless they've already used it, in which case they've moved past an FAQ. Oh, but that kind of

[Haskell-cafe] list monad and controlling the backtracking

2006-11-23 Thread isto
Hi all, Weekly news had a link to article Local and global side effects with monad transformers and the following is from there (minor modification done): import Control.Monad.List import Control.Monad.State import Control.Monad.Writer test5 :: StateT Integer (ListT (Writer [Char])) Integer

Re: [Haskell-cafe] type keeping rounding, typeable (and a difficulty)

2006-11-23 Thread isto
Hi thanks! to, 2006-11-16 kello 14:02 -0800, Greg Buchholz kirjoitti: ] I'll guess the reason it didn't compile was different ] types at case branches (am I wrong?) Correct. ] Anyhow, do you know that is it possible to choose the return type ] somehow in the spirit above?

[Haskell-cafe] Re: list monad and controlling the backtracking

2006-11-23 Thread Benjamin Franksen
isto wrote: Hi all, Weekly news had a link to article Local and global side effects with monad transformers and the following is from there (minor modification done): import Control.Monad.List import Control.Monad.State import Control.Monad.Writer test5 :: StateT Integer (ListT

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Jason Dagit
On 11/23/06, Dougal Stanton [EMAIL PROTECTED] wrote: Is there some sort of equivalent of the if/then/else construct for use in the IO monad? For instance the following can get quite tedious: do bool - doesFileExist filename if bool then sth else sth' Is there a more compact way of

[Haskell-cafe] Re: Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Benjamin Franksen
Dougal Stanton wrote: Is there some sort of equivalent of the if/then/else construct for use in the IO monad? For instance the following can get quite tedious: do bool - doesFileExist filename if bool then sth else sth' Is there a more compact way of writing that? Something

Re: [Haskell-cafe] SimonPJ and Tim Harris explain STM - video

2006-11-23 Thread Cale Gibbard
On 23/11/06, Jason Dagit [EMAIL PROTECTED] wrote: A comment on that video said: - BEGIN QUOTE It seems to me that STM creates new problems with composability. You create two classes of code: atomic methods and non atomic methods. Nonatomic methods can easily call atomic ones – the

Re: [Haskell-cafe] SimonPJ and Tim Harris explain STM - video

2006-11-23 Thread Benjamin Franksen
[sorry for quoting so much, kinda hard to decide here where to snip] Cale Gibbard wrote: On 23/11/06, Jason Dagit [EMAIL PROTECTED] wrote: A comment on that video said: - BEGIN QUOTE It seems to me that STM creates new problems with composability. You create two classes of code:

RE: [Haskell] Re: [Haskell-cafe] SimonPJ and Tim Harris explain STM - video

2006-11-23 Thread Tim Harris (RESEARCH)
(Dropping [EMAIL PROTECTED]) Hi, We've not yet looked at I/O in detail in Haskell, but there's a paper from a few years back where I experimented with ways of integrating I/O with an earlier implementation of atomic blocks in Java. http://research.microsoft.com/~tharris/papers/2005-scp.pdf

Re: [Haskell-cafe] type keeping rounding, typeable (and a difficulty)

2006-11-23 Thread John Meacham
On Thu, Nov 16, 2006 at 10:44:59PM +0200, isto wrote: I'll guess the reason it didn't compile was different types at case branches (am I wrong?) Anyhow, do you know that is it possible to choose the return type somehow in the spirit above? GADTs let you do this. And they even omit the

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Henk-Jan van Tuyl
You can use 'when' or 'unless' from the module Control.Monad, but they each have only one branch, see: http://members.chello.nl/hjgtuyl/tourdemonad.html#unless and http://members.chello.nl/hjgtuyl/tourdemonad.html#when You can create a monadic 'if' like this (in an interactive session):

Re: [Haskell] Re: [Haskell-cafe] SimonPJ and Tim Harris explain STM - video

2006-11-23 Thread Liyang HU
Hi, On 23/11/06, Benjamin Franksen [EMAIL PROTECTED] wrote: One answer is in fact to make it so that Console.Write can be rolled back too. To achieve this one can factor the actual output to another task and inside the transaction merely send the message to a transactional channel (TChan):

Re: [Haskell-cafe] working with lists of couples

2006-11-23 Thread Clare
Yes the code you are suggesting is certainly linear and it takes without doubt time n. But I was looking for a solution using foldl that of course takes time n. The problem of the following solution is that it gives a reversed result, and of course i can't just reverse the result. couples = snd

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Conor McBride
Jason Dagit wrote: On 11/23/06, Dougal Stanton [EMAIL PROTECTED] wrote: Is there some sort of equivalent of the if/then/else construct for use in the IO monad? For instance the following can get quite tedious: do bool - doesFileExist filename if bool then sth else sth' Is there a

[Haskell-cafe] Re: [Haskell] Re: SimonPJ and Tim Harris explain STM - video

2006-11-23 Thread Benjamin Franksen
Hi Liyang HU you wrote: On 23/11/06, Benjamin Franksen [EMAIL PROTECTED] wrote: One answer is in fact to make it so that Console.Write can be rolled back too. To achieve this one can factor the actual output to another task and inside the transaction merely send the message to a

Re: [Haskell-cafe] Command line prompt templates

2006-11-23 Thread Donald Bruce Stewart
ithika: I was trying to write my own equivalent to Don Stewart's mkcabal but ended up getting sidetracked. I made some generalised prompts for use at the command line and wanted to get some feedback on them. The full code can be found at [1] but the basic summary is like this: prompt ::

[Haskell-cafe] strange type mismatch when trying to use takusen

2006-11-23 Thread Seth Gordon
I have a simple test program for takusen and PostgreSQL: import Database.Enumerator import Database.PostgreSQL.Enumerator import Control.Monad.Trans gazdbSession dbname = connect [CAdbname dbname] resultCollector :: (Monad m) = String - IterAct m [String] resultCollector str accum = result'

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Luis F. Araujo
Dougal Stanton wrote: Is there some sort of equivalent of the if/then/else construct for use in the IO monad? For instance the following can get quite tedious: do bool - doesFileExist filename if bool then sth else sth' Is there a more compact way of writing that?

Re: [Haskell-cafe] strange type mismatch when trying to use takusen

2006-11-23 Thread Taral
On 11/23/06, Seth Gordon [EMAIL PROTECTED] wrote: takusen-test.hs:11:57: Couldn't match expected type `forall mark. DBM mark Session a' against inferred type `DBM mark sess ()' In the second argument of `($)', namely `main'' In the expression: (withSession

Re: [Haskell-cafe] question about How to Write a Haskell Program tutorial

2006-11-23 Thread Donald Bruce Stewart
mvanier: First off, I apologize if this has come up before. As far as I can tell, the mailing list archives don't have a search function. I'm running ghc-6.6 and haddock-0.8, both compiled from source. I'm working my way through the How to Write a Haskell Program tutorial (which is a

Re: [Haskell-cafe] Command line prompt templates

2006-11-23 Thread Antti-Juhani Kaijanaho
Donald Bruce Stewart wrote: Looks pretty good, though you use case x :: Bool of True - ... False - ... when if x then ... else ... would be preferred. Why? Personally, I find boolean case to feel better wrt layout and I see no loss of clarity in its use.