Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Haskell does not do this. Haskell is lazy (computed results are shared), but Haskell does not memoize by default. To illustrate:

    func y = let z = y + y
             in (add 1 z) * (add 1 z)
in `func` the result of computing `y + y` is shared because it has been given a name: `z`. However, the result of `add 1 z` is _not_ given a name and therefore has to be computed twice. Because Haskell is pure, they will result return the same result, however the result is not saved.

This avoids needing to save the results of _all_ function calls.



That's a bad example, since GHC will perform common expressions elimination, which effectively give the same name to the two `add 1 z` (unless you specifically ask it not to, with `-O0`.)

Furthermore, Incremental isn't memoizing every function calls. It just keeps the intermediate results of the latest computation in memory, so that when the inputs change, it can determine exactly which subresults need a recomputation, and which can be reused. It's like Excel, but with dynamic dependencies.

(But yes, Haskell definitively does not do this. You could say that Haskell is about doing the least amount of work to compute something fresh, while Incremental is about working the least to recompute something we (almost) already computed just before.)


A better example might have been

    func (f (add 1 z), f (add z 1))
Since f is not memoized it will be evaluated once for each component of the tuple.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: