Re: laziness in `length'

2010-06-15 Thread Roman Beslik
On 14.06.10 17:25, Serge D. Mechveliani wrote: lng [1 .. n] = lng (1 : (list 2 n)) = 1 + (lng $ list 2 n) = 1 + (lng (2: (list 3 n))) = 1 + 1 + (lng $ list 3 n) = {- !!! -} 2 + (lng (3: (list 4 n))) -- because this "+" is of Integer = 2 + 1 + (lng $ list 4 n) = {- !!! -} 3 + (lng $

Re: laziness in `length'

2010-06-15 Thread Roman Beslik
Hello. On 15.06.10 17:52, Denys Rtveliashvili wrote: Please could you explain which Nums are not strict? The ones I am aware about are all strict. Any value of any type is not strict in Haskell. Also, why doesn't it require building the full thunk for non-strict Nums? Even if they are not stri

Re: laziness in `length'

2010-06-15 Thread Daniel Fischer
On Tuesday 15 June 2010 16:52:04, Denys Rtveliashvili wrote: > Hi Daniel, > > Thank you very much for the explanation of this issue. > > While I understand the parts about rewrite rules and the big thunk, it > is still not clear why it is the way it is. > > Please could you explain which Nums are n

Re: laziness in `length'

2010-06-15 Thread Denys Rtveliashvili
Hi Daniel, Thank you very much for the explanation of this issue. While I understand the parts about rewrite rules and the big thunk, it is still not clear why it is the way it is. Please could you explain which Nums are not strict? The ones I am aware about are all strict. Also, why doesn't it

Re: laziness in `length'

2010-06-14 Thread Daniel Fischer
On Monday 14 June 2010 16:25:06, Serge D. Mechveliani wrote: > Dear people and GHC team, > > I have a naive question about the compiler and library of ghc-6.12.3. > Consider the program > > import List (genericLength) > main = putStr $ shows (genericLength [1 .. n]) "\n" > where >

laziness in `length'

2010-06-14 Thread Serge D. Mechveliani
Dear people and GHC team, I have a naive question about the compiler and library of ghc-6.12.3. Consider the program import List (genericLength) main = putStr $ shows (genericLength [1 .. n]) "\n" where n = -- 10^6, 10^7, 10^8 ... (1) When it is compiled under -O,