On Fri 27 Aug, Simon Peyton-Jones wrote:
func n = map (func' n) [1..10]
func' x y = nfib x
There isn't a free subexpression to lift out of func.
I had always imagined that in a fully lazy language a function like Mike
Thyers example would get transformed into something like this..
func
There's a whole chapter on full laziness in my book;
and a paper in Software Practice and Experience
A modular fully-lazy lambda lifter in Haskell, SL Peyton Jones and D Lester,
Software Practice and Experience 21(5), May 1991, pp479-506.
The latter is available on my publications page
D.Tweed wrote:
Marko Schuetz wrote:
What I would like to know is: wouldn't it make sense to have the
transformation
f x = e where e does not mention x
--
f x = f'
f' = e
in hugs? Did I miss anything?
What if e if huge (maybe an infinte list of primes) and f x
I think that the transformation is exactly fully laziness.
Sometimes, it
helps to improve space/time performance, but it needs to be tunned up
due to the reasons including one given by Tweed.
GHC does full laziness(*). As far as I know, no-one ever complained :)
Simon
(*) Well, actually
IIRC, GHC does the tuning, i.e. CAFs are garbage collected in a clever
way (describe in SPJ's book, I think), e.g. if there is only one
reference into the "middle" of a CAF left, only that part is
kept alive.
and not the wohle CAF. Comments from Mr. GC? :-)
True, but this doesn't solve
On 25 Aug 1999, Marko Schuetz wrote:
What I would like to know is: wouldn't it make sense to have the
transformation
f x = e where e does not mention x
--
f x = f'
f' = e
in hugs? Did I miss anything?
What if e if huge (maybe an infinte list of primes) and f x is used only
very
A student asked me why the following happens. In explaining I thought
that it may be easy to avoid the observed behavior.
In hugs98, when you input
paired f (x,y) = (f x, f y)
pair x = (x,x)
test1 = paired f $ pair 42
where f x = length [1..1]
test2 = paired (\x - y) $ pair 42