3 ms·
> You cannot ask a strict function to behave lazily. But you can ask a lazy function to behave strictly. Huh? I suggest that when you don't annotate anything,
by eru 3y ago
> You cannot ask a strict function to behave lazily. But you can ask a lazy function to behave strictly.
Huh? I suggest that when you don't annotate anything, you can only use constructs that can be evaluated in any order (including both lazy and strict or any other order). So the compiler has maximal freedom.
So your supposed impossibility doesn't come into play: we are not dealing with arbitrary functions.
If your function needs a specific evaluation order, you'd need to tag that.
- mrkeen 3y agoYou can walk an expression and replace its thunks with the values that those thunks deferred the evaluation of. To do the reverse would require uncomputation. You can't turn all the natural numbers back into the expression [1..].