On Mon, Jul 22, 2013 at 04:16:19PM +0200, Andreas Abel wrote: > In general, I would not trust such compiler magic, but just let-bind > anything I want memoized myself: > > memoized_fib :: Int -> Integer > memoized_fib x = fibs !! x > where fibs = map fib [0..] -- lazily computed infinite list > fib 0 = 0 > fib 1 = 1 > fib n = memoized_fib (n-2) + memoized_fib (n-1) > > The eta-expansions do not matter.
But this is *not* memoized (run it and see!). The "eta-expansions" do indeed matter (although I don't think they are truly eta-expasions because of the desugaring of the where to a let). What matters is not the let binding, but where the let binding occurs in relation to the lambda. There's no compiler magic here, just operational semantics. Tom _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe