News for hackers. Stuff that matters.
Re:Dynamic programming in Haskell: automatic memoization by gloria_mundi on Tuesday June 20, 2023 @04:21AM (#36401114)
> To be absolutely clear, the expressions `seq f (putStrLn "hello")` and `seq (f undefined) (putStrLn "hello")` should both not evaluate anything and cause the string hello to be printed rather than raising an exception.

This does actually work here, because the array is created lazily.

> This often occurs in cases where the above hypothetical function `f` requires an intermediate value that's expensive to compute but only relies on the first of its two arguments. Then do you evaluate that expensive intermediate with a partial application of a single argument, or do you not? Neither is satisfactory and so this problem is best avoided.

Computing the intermediate value with a partial application does not actually take away laziness, it only adds sharing. (At least it can be done this way.)

There are no comments on this comment yet.