Hi,

I believe, without checking, that

Am Sonntag, den 24.02.2013, 17:49 +0000 schrieb Tom Ellis:
> many :: () -> [Int]
> many () = [1..million]

is indeed called many times. The problem is that [1..million] is not
dependent on the parameter, so GHC will float it out to a top level
declaration, and hence share it between the multiple calls to many.

You should try:

> million :: () -> Int
> million _ = 10 ^ (6 :: Int)
>
> many :: () -> [Int]
> many x = [1..million x]

Greetings,
Joachim

(Maybe I should continue to work on http://arxiv.org/abs/1106.3478 and
related ideas, like annotating thunks in the code as unshareable... or
does this mostly occur in small example programs like this?)

-- 
Joachim "nomeata" Breitner
Debian Developer
  nome...@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nome...@joachim-breitner.de | http://people.debian.org/~nomeata

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to