forked from lix-project/lix
![sternenseemann](/assets/img/avatar_default.png)
* Clarify the documentation of foldl': That the arguments are forced before application (?) of `op` is necessarily true. What is important to stress is that we force every application of `op`, even when the value turns out to be unused. * Move the example before the comment about strictness to make it less confusing: It is a general example and doesn't really showcase anything about foldl' strictness. * Add test cases which nail down aspects of foldl' strictness: * The initial accumulator value is not forced unconditionally. * Applications of op are forced. * The list elements are not forced unconditionally.
7 lines
271 B
Nix
7 lines
271 B
Nix
# Checks that the nul value for the accumulator is not forced unconditionally.
|
|
# Some languages provide a foldl' that is strict in this argument, but Nix does not.
|
|
builtins.foldl'
|
|
(_: x: x)
|
|
(throw "This is never forced")
|
|
[ "but the results of applying op are" 42 ]
|