Re: [Haskell-cafe] GHC predictability

2008-05-12 Thread Abhay Parvate
As a beginner, I had found the behaviour quite unpredictable. But with time I found that I could reason out the behaviour with my slowly growing knowledge of laziness. I don't spot all the places in my program that will suck while writing a program, but post facto many things become clear. (And

Re: [Haskell-cafe] List concat

2008-05-12 Thread ajb
G'day all. Quoting Andrew Coppin [EMAIL PROTECTED]: The function (++) :: [x] - [x] - [x] has O(n) complexity. That's not entirely true. When you call (++), it does O(1) work. If you evaluate k cons cells. it takes O(min(k,n)) work. Cheers, Andrew Bromage

[Haskell-cafe] Re: Couple of formal questions

2008-05-12 Thread Dominic Steinitz
Creighton Hogg wchogg at gmail.com writes: between well-founded recursion well-founded(?) corecursion?Where could I find a proof that the initial algebras final coalgebras of CPO coincide?  I Creighton, I started putting something together here. I'm not sure if it's what you are after and

[Haskell-cafe] help(!!)

2008-05-12 Thread Galchin, Vasili
Hello, As I said in a Friday posting, I changed the version # of the cabal file that I am using, unix.cabal. Now my build environment is broken and I am dead in the water: [EMAIL PROTECTED]:~/FTP/Haskell/unix-2.2.0.0$ runhaskell Setup.hs configure Configuring unix-2.3.0.0... [EMAIL

Re: [Haskell-cafe] saner shootout programs

2008-05-12 Thread Benjamin L. Russell
--- On Mon, 5/12/08, PR Stanley [EMAIL PROTECTED] wrote: I don't know Haskell very well, but Paul: I'm not racist but . . . :-) Relevant Haskell humor: Humor/Homework - HaskellWiki: see line 3: http://www.haskell.org/haskellwiki/Humor/Homework Benjamin L. Russell

Re: [Haskell-cafe] help(!!)

2008-05-12 Thread Duncan Coutts
On Mon, 2008-05-12 at 04:00 -0500, Galchin, Vasili wrote: Hello, As I said in a Friday posting, I changed the version # of the cabal file that I am using, unix.cabal. Now my build environment is broken and I am dead in the water: [EMAIL PROTECTED]:~/FTP/Haskell/unix-2.2.0.0$

Re: [Haskell-cafe] saner shootout programs

2008-05-12 Thread Richard Kelsall
J C wrote: ... If anyone has a version of the N-body benchmark, where the simulation is a type-safe pure function, I would very much like to see and time it. Hello JC, I think you've set yourself a challenge there :) Welcome to Haskell programming. Taking a Shootout entry and playing with it

[Haskell-cafe] M1 + M2 = M3 where both computations in M1 and M2 can be used?

2008-05-12 Thread sam lee
Hi. I want to compose two monads to build another monad where computations of the two monads can be used inside. I have: - MonadTypeInfer : interface (class) for TypeInfer monad - TypeInfer : a monad that has Map String Type (association of names and types) - TypeInferT : transformer of above

Re: [Haskell-cafe] M1 + M2 = M3 where both computations in M1 and M2 can be used?

2008-05-12 Thread Twan van Laarhoven
sam lee wrote: Hi. I want to compose two monads to build another monad where computations of the two monads can be used inside. I have: - MonadTypeInfer : interface (class) for TypeInfer monad - TypeInfer : a monad that has Map String Type (association of names and types) - TypeInferT :

[Haskell-cafe] On syntactic sugar

2008-05-12 Thread Lauri Oksanen
Hi, I'm writing my first real Haskell program and I came up with the following code snippet. --- let x' = x \+ dist \* dir nx' = normal geometry wi = (-1) \* dir in do (p, wo) - brdfCosSampling reflector nx' wi let color' = p \** color q = min 1

Re: [Haskell-cafe] M1 + M2 = M3 where both computations in M1 and M2 can be used?

2008-05-12 Thread Kenn Knowles
On Mon, May 12, 2008 at 6:51 AM, sam lee [EMAIL PROTECTED] wrote: Hi. I want to compose two monads to build another monad where computations of the two monads can be used inside. Twan's suggestion seems like a natural way to continue with the existing code you have described (based on monad

Re: [Haskell-cafe] Re: [Haskell] Re: ANN: Haddock version 2.1.0

2008-05-12 Thread David Waern
2008/5/9 Claus Reinke [EMAIL PROTECTED]: Ah, I didn't think about the GHC options that change the lexical syntax. You're right, using the GHC lexer should be easier. and, if you do that, you could also make the GHC lexer squirrel away the comments (including pragmas, if they aren't

Re: [Haskell-cafe] GHC predictability

2008-05-12 Thread Andrew Coppin
Don Stewart wrote: jeff.polakow: Hello, One frequent criticism of Haskell (and by extension GHC) is that it has unpredictable performance and memory consumption. I personally do not find this to be the case. I suspect that most programmer confusion is rooted in shaky

Re: [Haskell-cafe] Copy on read

2008-05-12 Thread Andrew Coppin
Matthew Naylor wrote: I wonder to what extent deforestation supersedes such optimisations. This would be a good topic to raise with a Cleaner. The paper Neil mentions looks like a nice alternative to uniqueness typing -- and it appears that there will be a FitA talk about it, this Thursday.

Re: [Haskell-cafe] List concat

2008-05-12 Thread Lennart Augustsson
Well, if you want to be picky evaluating (calling) (xs ++ ys) takes whatever time it takes to evaluate xs to WHNF and if xs is null then it in addition takes the time it takes to evaluate ys to WHNF. Saying anything about time complexity with lazy evaluation requires a lot of context to be exact.

[Haskell-cafe] Short circuiting and the Maybe monad

2008-05-12 Thread John Hamilton
I'm trying to understand how short circuiting works with the Maybe monad. Take the expression n = f = g = h, which can be written as (((n = f) = g) = h) because = is left associative. If n is Nothing, this implies that (n = f) is Nothing, and so on, each nested sub-expression easily evaluating to

Re: [Haskell-cafe] M1 + M2 = M3 where both computations in M1 and M2 can be used?

2008-05-12 Thread sam lee
tInfer :: MonadTypeInfer m = Expr - m Type eval :: MonadEval m = Expr - m Expr That solves! I should've left out type annotation. On Mon, May 12, 2008 at 10:38 AM, Twan van Laarhoven [EMAIL PROTECTED] wrote: sam lee wrote: Hi. I want to compose two monads to build another

Re: [Haskell-cafe] GHC predictability

2008-05-12 Thread Duncan Coutts
On Mon, 2008-05-12 at 20:01 +0100, Andrew Coppin wrote: In short, as a fairly new Haskell programmer, I find it completely impossibly to write code that doesn't crawl along at a snail's pace. Even when I manage to make it faster, I usually have no clue why. (E.g., adding a seq to a

Re: [Haskell-cafe] GHC predictability

2008-05-12 Thread Yitzchak Gale
Andrew Coppin wrote: I offer up the following example: mean xs = sum xs / length xs Now try, say, mean [1.. 1e9], and watch GHC eat several GB of RAM. (!!) If we now rearrange this to mean = (\(s,n) - s / n) . foldr (\x (s,n) - let s' = s+x; n' = n+1 in s' `seq` n' `seq` (s', n'))