Hello
One thing is magic for me: how GHC can know what function results to
remember and what results can be forgotten ?
Is it just a stupid buffer algorithm or is there some mathematics
truths behind this ?
I'm very happy about Haskell, it's so great to put some smart ideas in
a computer.
thank
On Thu, 3 Dec 2009, Emmanuel CHANTREAU wrote:
Hello
One thing is magic for me: how GHC can know what function results to
remember and what results can be forgotten ?
Is it just a stupid buffer algorithm or is there some mathematics
truths behind this ?
Although it is not required by the Has
Hi.
There is actually no magic at all going on. Haskell has a reasonably
well-defined evaluation model; you can approximate it, at least not
taking IO into account, with lazy graph reduction (look that up on
google). Probably that is the "mathematical truth" you're looking for.
Actually, if Haske
Does this really mean that you want to know how the garbage collector works?
Emmanuel CHANTREAU wrote:
Hello
One thing is magic for me: how GHC can know what function results to
remember and what results can be forgotten ?
Is it just a stupid buffer algorithm or is there some mathematics
truth
Hello
First, thank you for all answers.
Le Thu, 03 Dec 2009 18:58:33 +0300,
Miguel Mitrofanov a écrit :
> Does this really mean that you want to know how the garbage collector
> works?
Well, I try to understand your question...
I will take an example:
f x y= x+y
The program ask the user to
> I will take an example:
>
> f x y= x+y
>
> The program ask the user to enter two numbers and print the sum. If the
> user enter "1 2" "f 1 2=3" is stored and a gargage collector is used to
> remove this dandling expression later ?
> If the user enter again "1 2", ghc search in dandling results to
I will take an example:
f x y= x+y
The program ask the user to enter two numbers and print the sum. If
the
user enter "1 2" "f 1 2=3" is stored and a gargage collector is used
to
remove this dandling expression later ?
It's not stored in any way.
If the user enter again "1 2", ghc searc
Emmanuel CHANTREAU wrote:
I will take an example:
f x y= x+y
The program ask the user to enter two numbers and print the sum. If the
user enter "1 2" "f 1 2=3" is stored and a gargage collector is used to
remove this dandling expression later ?
If the user enter again "1 2", ghc search in dandl
On Fri, Dec 4, 2009 at 3:36 AM, Neil Brown wrote:
> But let's say you have:
>
> g x y = f x y * f x y
>
> Now the compiler (i.e. at compile-time) can do some magic. It can spot the
> common expression and know the result of f x y must be the same both times,
> so it can convert to:
>
> g x y = le
Hi,
Am Freitag, den 04.12.2009, 10:36 + schrieb Neil Brown:
> But let's say you have:
>
> g x y = f x y * f x y
>
> Now the compiler (i.e. at compile-time) can do some magic. It can
> spot the common expression and know the result of f x y must be the
> same both times, so it can convert to
On Dec 4, 2009, at 2:43 AM, Luke Palmer wrote:
> So GHC leaves it to the user to specify sharing. If you want an
> expression shared, let bind it and reuse.
Does GHC treat where and let the same in this regard? Or in code, are these
treated the same?
> x'' = sum l + product l where l = [1..10
On Fri, Dec 4, 2009 at 9:44 AM, Mark Lentczner wrote:
>
> On Dec 4, 2009, at 2:43 AM, Luke Palmer wrote:
>
>> So GHC leaves it to the user to specify sharing. If you want an
>> expression shared, let bind it and reuse.
>
> Does GHC treat where and let the same in this regard? Or in code, are thes
Although, in Luke's example,
> x = sum [1..10^6] + product [1..10^6]
> x' = let l = [1..10^6] in sum l + product l
We can do much much better, if we're sufficiently smart.
-- Define:
bar m n = foo (enumFromTo m n)
foo xs = sum xs + prod xs
-- We're given:
sum = foldl (+) 0
product = foldl (*)
2009/12/4 Evan Laforge :
> The interesting thing is CAFs, which at the top level will never be
> out of scope and hence live forever.
Untrue! CAFs can be garbage collected as well. See:
http://www.haskell.org/pipermail/glasgow-haskell-users/2005-September/009051.html
_
Fixing my errors:
> x = sum [1..10^6] + product [1..10^6]
> x' = let l = [1..10^6] in sum l + product l
-- Define:
bar m n = foo (enumFromTo m n)
foo xs = sum xs + prod xs
-- We're given:
sum = foldl (+) 0
product = foldl (*) 1
foldl f z xs =
case xs of
[] -> []
x:xs -> foldl f (f z x
Luke Palmer wrote:
On Fri, Dec 4, 2009 at 9:44 AM, Mark Lentczner wrote:
On Dec 4, 2009, at 2:43 AM, Luke Palmer wrote:
So GHC leaves it to the user to specify sharing. If you want an
expression shared, let bind it and reuse.
Does GHC treat where and let the same in this regard? Or in code,
16 matches
Mail list logo